Hi guys,
I'm wondering if i can create a custom validation rule.
I currently have this schema :
const schema = Joi.object().keys({
businessName: Joi.string().required(),
slug: Joi.string().regex(SLUG).required(),
description: Joi.string().required(),
}).required();
And i want to had another rule to my slug for it to be uniq by checking in my DB, so i would like to have something like :
const schema = Joi.object().keys({
businessName: Joi.string().required(),
slug: Joi.string().regex(SLUG).isSlugUniq().required(),
description: Joi.string().required(),
}).required();
Do you know if i can do this ? Can you tell me how ? (I did not find anything about this on issues list )
Thank you
EDIT : Ok i filtered my issue with not closed. I found this : https://gist.github.com/Marsup/14597d0c8eaa10c4addb and currently reading. My issue is on stand-by. I'll close it if this answers my question.
You can't, extensions are not yet async, unless you find a sync way this is not possible.
Ah ! But this article for Joi 7.0.0 seems to indicates otherwise… But ok.
This is not an article, this is a proposal.
Ah ^^ ok. I thought after 7 month and the enthousiasm of developers it would have been implemented :)
Thank you anyway.
The enthusiasm of developers doesn't have much influence on the time I can spend on it unless they are enthusiastic enough to do PRs :)
Most helpful comment
The enthusiasm of developers doesn't have much influence on the time I can spend on it unless they are enthusiastic enough to do PRs :)