backbone.validation icon indicating copy to clipboard operation
backbone.validation copied to clipboard

Array of custom validators only works if each validator is wrapped in an object

Open fridays opened this issue 8 years ago • 0 comments

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.

fridays avatar Mar 19 '16 06:03 fridays