-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Context
- node version: v14.19.0
- module version: 17.6.0
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...): standalone
- any other relevant information: none
How can we help?
I want to retrieve the rule name which trigger my external validation, this helper is not available with any.external. I need it like of any.custom() with helpers.state.path[0]
Joi.object({
//...
email: Joi.string().external(uniqueRecord)
})
const uniqueRecord = async (value: any, helpers: any): Promise<any> => {
//const field = "here the value will be email"
const tenant = helpers.prefs.context.tenant;
const collection = helpers.prefs.context.collection;
const query = await db.query(tenant, collection)
const isUnique = await query.find({[field]: value}).count() === 0
if(!isUnique){
console.warn('uniqueRecord : not unique');
return helpers.error('any.invalid')
} else {
console.log('uniqueRecord : unique');
return undefined
}
}I tried to use description like on doc, but I can't retrieve it on my external function.
Thanks,
Metadata
Metadata
Assignees
Labels
No labels