Hapi route joi password confirmation confirmation
2 answers
You can use Joi.any().valid()
with Joi.ref()
:
password: Joi.string().min(3).max(15).required(),
password_confirmation: Joi.any().valid(Joi.ref('password')).required().options({ language: { any: { allowOnly: 'must match password' } } })
+22
source to share
I have to resurrect this thread because I tried the code above and the validation error worked even though the password and password confirmation match.
I spent several hours trying several approaches but still no luck, the check still runs, e.g .:
password: Joi.string (). min (5) .required (), password Confirmation: Joi.ref ("password")
Here is my state facility:
data: {…} email: "" password: "12345" passwordConfirmation: "12345" username: "" error: {…} passwordConfirmation: "\" passwordConfirmation \ "must be one of [ref: password]"
I have other validations on this form and they are working fine.
0
source to share