To use this mapper you need to define which error class it will map. Each instance of your validation failed error should have all violations on the errors property.
Will respond with 400 status and the following body:
{
"message":"Validation failed",
"code":"validation_failed",
"errors":{
"foo":[{
"code":"not_blank",
"message":"This value must not be blank"
}],
"bar":[{
"args":{
"min":1,
"max":2
},
"code":"length",
"message":"This value must have between 1 and 2 characters"
}]
}
}
Messages
All asserts from validator.js and validator.js-asserts have pre-defined messages, although you can override them and add your own custom messages as the mapper second constructor argument.
The message property can be defined as a function that receives the violation or a template string to generate more dynamic output.
The args property can also be defined as a function that receives the violation or a list of strings that should match the assert's properties.