Joi renvoie l'erreur suivante même si tel
est défini sur en option. Comment réparons nous ça?Joi: "tel" n'est pas autorisé à être vide
Merci.
Error: Joi Failed: ValidationError: child "tel" fails because ["tel" is not allowed to be empty]
//Define Joi schema
const schema = {
email: Joi.string().required().email({
errorLevel: 64,
minDomainAtoms: 2
}).min(6),
tel: Joi.string().optional().min(10).max(10),
password: Joi.string().required().min(8).max(64)
}
//Check inputs
const { error, value } = Joi.validate({
email: args.email,
tel: tel,
password: args.password
}, schema)
[* "Notez que les chaînes vides ne sont pas autorisés par défaut et doivent être activées avec 'allow ('')'. "*] (https://github.com/hapijs/joi/blob/v10.6.0/API.md#string- --inhérite-de-tout) – jonrsharpe
Merci. Cela a résolu parfaitement. – Kainan