How do I check that password and password_confirmation are the same ?
var Joi = require('joi'),
S = Joi.string().required().min(3).max(15);
exports.create = {
payload: {
username: S,
email: Joi.string().email(),
password: S,
password_confirmation: S
}
}
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' } } })