-
Notifications
You must be signed in to change notification settings - Fork 8
Joi
Cláudio Medeiros edited this page Oct 5, 2022
·
3 revisions
import { validateOrFail } from "validation-br/dist/cpf";
const isCPF = (value: string | number, helper: any) => {
try {
validateOrFail(value);
return value;
} catch (error: any) {
return helper.message(error.message);
}
};
const Joi = require('@hapi/joi');
Joi.object({
cpf: Joi.string().custom(isCPF) // <- Função personalizada
}).validate({
cpf: '01234567890'
});