fastest-validator
fastest-validator copied to clipboard
Incomplete error message when parameter object is undefined
If I have a schema like:
const eventSchema = { id: 'string' };
const eventSchemaCheck = validator.compile(eventSchema);
and I pass in an undefined object as a parameter:
const payload = undefined
const schemaCheck: boolean | ValidationError[] = eventSchemaCheck(
payload
);
if (schemaCheck !== true) {
this.logger.error(
`Validation check failed!
${JSON.stringify(schemaCheck)}`
);
}
The error message has a blank string for the field name:
console.error node_modules/moleculer/src/loggers/console.js:191
[2020-01-20T06:48:58.130Z] ERROR yama-4147/SAMPLE: Validation check failed!
[{"type":"required","message":"The '' field is required.","actual":null}]
Thansk, I will check it.
It's normal because the whole root payload object is missing, so no field value.
Ok, but I was hoping the error message would still be a little more clear? Or maybe just say that payload object itself is missing?