Login

Tag "cpf"

Snippet List

CNPJ and CPF Validation for Models

The code was placed inside a helper file without using a class. The Django validator was not designed to work with validator classes, it would appear, so retrieving the value from the field proved to be a hassle. Just create a helper file, import it on your model, and use the validator in the standard way, as such: cnpj = models.CharField(unique=True, max_length=14, validators=[validate_CNPJ]) cpf = models.CharField(unique=True, max_length=14, validators=[validate_CPF])

  • model
  • validation
  • cnpj
  • cpf
Read More

Campo para Validar CPF ou CNPJ Brasileiro

I basically mixed both BRCPFField and BRCNPJField to create a widget that validates either an CPF or an CNPJ. The doc strings are not localized. So you probably have to hardcode it yourself.

  • validation
  • field
  • widget
  • brazil
  • brasil
  • cnpj
  • cpf
Read More

2 snippets posted so far.