validators icon indicating copy to clipboard operation
validators copied to clipboard

How to validate not required CPF field

Open Xavoski opened this issue 5 years ago • 1 comments

Hello. Thanks for your work.

I am in trouble with this gem, it validates the CPF properly. But the problem is that my CPF field is not required. When i try to submit my form, i receive the message that CPF is invalid, but actually it is null and that is ok.

Could you help me with that?

Thanks.

Xavoski avatar Oct 26 '20 20:10 Xavoski

@Xavoski you can use validates :cpf, allow_nil: true, cpf: true to allow nil.

wbotelhos avatar Mar 31 '25 12:03 wbotelhos