I am trying to understand how to make custom errors in custom validators, and what properties I can control with it. But I can't seem to figure out the syntax of it.
helpers.message({ message: 'hello world', code: 'any.custom', details: 'hi' });
helpers.error('string.UUID', { key: 'properties', value: 'what' });
helpers.error('string.UUID')
const bookSchema = Joi.object({
title: Joi.string().required().error((error)=>{
return {
message:'title is must'
}
}).label('title'),
author: Joi.string().required(),
});
Getting error after executing this code :
Error :
Error: error() must return an Error object
Thanks
Unfortunately, no community resources were available to help resolve this issue after two weeks, and it is being closed. We close unresolved community issues to keep the issue tracker organized and effective. Please check https://hapi.dev/support for other support options.
@TheFedaikin helpers.message({ custom: 'hello world' }); should work
Most helpful comment
@TheFedaikin
helpers.message({ custom: 'hello world' });should work