var schema = {
type: 'object',
required: ['foo', 'bar'],
errorMessage: {
required: {
foo: 'missing foo property',
bar: 'missing bar property'
}
}
Processed errors:
[
{
keyword: 'errorMessage',
message: 'missing foo property',
dataPath: '',
// ...
},
{
keyword: 'errorMessage',
message: 'missing bar property',
dataPath: '',
// ...
}
]
It is difficult to know which error message was generated for which property.
It is needed for automatic processing.
Now there are two possible workarounds:
- format error message in a special way (include missing property name) and process it afterwards
- check param.errors[0].missingProperty - here we have to make sure that param.errors[0].keyword==="required"
Suggestion:
Add name of missing property to dataPath. This is possible only when property specific message is defined.
Another suggestion:
Add option allowing to have separate messages for missing properties (even if single error message is defined for all missing properties). This would allow to have correct dataPath settings for every missing property.
Processed errors:
It is difficult to know which error message was generated for which property.
It is needed for automatic processing.
Now there are two possible workarounds:
Suggestion:
Add name of missing property to dataPath. This is possible only when property specific message is defined.
Another suggestion:
Add option allowing to have separate messages for missing properties (even if single error message is defined for all missing properties). This would allow to have correct dataPath settings for every missing property.