I am currently working on creating a validation function for user input
async function validateUserInput(user) {
const schema = Joi.object({
password: Joi.string().pattern((new RegExp('^[a-zA-Z0-9]{3,30}$'))),
repeat_password: Joi.any().equal(Joi.ref('password')).required().messages({ 'any.only': '{{#label}} does not match' }),
email: Joi.string().email({ minDomainSegments: 2, tlds: { allow: ['com', 'dk']}})
});
try {
const value = await schema.validateAsync((user));
} catch (err) {
console.log(err)
}
}
However, I am encountering an issue with the repeat_password field,
firstname: 'Mette ',
lastname: 'Nielsen',
age: "'35'",
gender: 'female',
about: 'I like to go and watch movies',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9cf1f9e8e8f9f2f5f9f0eff9f2dcaeafaea8a9b2fbfdfbfd">[email protected]</a>',
password: 'metteNielsen123',
repeat_password: 'mette',
likes: 'Shopping, going to the mall, cities',
dislikes: 'rap musik, events, poor people'