'Confirm password validation is not working in react hook form + joi
Confirm password validation is not working here and also error is not showing until I submit it.
const schema = joi
.object({
fullName: joi.string().min(5).max(255).required(),
username: joi.string().min(5).max(255).required(),
email: joi
.string()
.email({ tlds: { allow: false } })
.pattern(new RegExp(patternForEmail))
.message('Invalid email address')
.required(),
password: joi
.string()
.pattern(new RegExp(patternForPassword))
.message(
'Password must contain at least one lowercase letter, one uppercase letter, one number and one special character and minimal length of 8 characters'
)
.required(),
confirmPassword: joi.string().required().valid(joi.ref('password')),
})
.with('password', 'confirmPassword');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
