How to add custom validator function in Joi?

const Joi = require('@hapi/joi');
    
Joi.object({
  password: Joi
    .string()
    .custom((value, helper) => {
      if (value.length < 8) {
        return helper.message("Password must be at least 8 characters long");
      }

      return true;
    })
}).validate({
    password: '1234'
});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)