fastest-validator
fastest-validator copied to clipboard
how to write enum types as a short hand ? + enum validation bug
hi, i want to write enum type and its values in shorthand syntax, but how?
'enum|values:1, 2'
it throws an error in the console :
/node_modules/fastest-validator/lib/rules/enum.js:10
${this.makeError({ type: "enumValue", expected: "\"" + schema.values.join(", ") + "\"", actual: "value", messages })}
TypeError: schema.values.join is not a function
also this doesnt work :
'enum|values:[1, 2]'
i got a bug with using normal syntax, the message of the validation is wrong, it says field value is 'pop, rap' but it should be the actual 'as' value...
[
{
type: 'enumValue',
message: "The 'category' field value 'pop, rap' does not match any of the allowed values.",
field: 'category',
expected: 'pop, rap',
actual: 'as'
}
]
Enum values have no shorthand format.