backbone.validation
backbone.validation copied to clipboard
Array of custom validators only works if each validator is wrapped in an object
I have an array of custom validator functions and tried this in the model:
validation: {
name: [validate.required, validate.user.name]
}
But it only works if I do this:
validation: {
name: [{ fn: validate.required }, { fn: validate.user.name }]
}
When only a single validator is provided, the library internally wraps it in an object { fn: attrValidation }
. But when an array of validators is provided, the library doesn't do this and expects each item to be already wrapped in this structure.