-
Notifications
You must be signed in to change notification settings - Fork 94
Closed
Description
Hi,
I have found a little bug using alias, to reproduce just:
const v = new Validator();
v.alias('algList', { type: "array", items: "string", enum: ['RS256' , 'PS256'] });
const toValidate = {
request_object_signing_alg_values_supported: ['RS256S']
}
const schema = {
request_object_signing_alg_values_supported: "algList"
};
const check = v.compile(schema);
console.log("First:", check(toValidate));
Im getting the error
/node_modules/fastest-validator/lib/rules/array.js:70
${this.makeError({ type: "arrayEnum", expected: "\"" + schema.enum.join(", ") + "\"", actual: "value[i]", messages })}
^
TypeError: schema.enum.join is not a function
After debug a bit i have seen that schema
has the value
{
type: 'array',
items: 'string',
enum: { '0': 'RS256', '1': 'PS256' }
}
The enum field has been modified for an Object, the problem is in /fastest-validator/lib/helpers/deep-extend.js
file because is checking object just with typeof source[property] === "object"
and this is also true for an array.
As possible solution i purpose to replace thia check with a source[property].constructor !== Object
or add an additional check in the same if like !Array.isArray(source[property]) &&
Best Regards.
Metadata
Metadata
Assignees
Labels
No labels