validatorjs
validatorjs copied to clipboard
Custom error messages for multiple auto-generated inputs
const data = {
'person.0.name': 'John',
'person.1.name': 'Kate',
}
const rules = {
'person.*.name': 'required'
}
const errorMessages = {
'required.person.*.name': 'Some custom error message' //prints out "The field person.0.name is required"
}
It works when I change key to required.person.0.name but not in the syntax I specified.
It seems like what new Validator(data, rules, errorMessages).errors.all() returns can't be mapped to the given error message because it has a placeholder * in it.
How do I modify it in the way so that I don't have to hardcode the indices?
Old issue, but still happening. Any news here?