xBacon v0.1.0 XBacon.Changeset.CPF
Defines a set of validations that can be applied on a changeset using the
XBacon.Matchers.CPF matchers.
Summary
Functions
Validates the given field on changeset inflecting the rules for CPF
Accepted formats are:
- xxx.xxx.xxx-xx
- xxxxxxxxx-xx
The validated field defaults to
cpffollowing the convetion of function name to change it you can pass a atom as second arity as the name of your field, example:validate_cpf(changeset, :cadastro_pessoa_fisica)
Validates the cpf format and also validates the verification digits
(the last two digits) from the changeset
Functions
Validates the given field on changeset inflecting the rules for CPF
Accepted formats are:
- xxx.xxx.xxx-xx
- xxxxxxxxx-xx
The validated field defaults to
cpffollowing the convetion of function name to change it you can pass a atom as second arity as the name of your field, example:validate_cpf(changeset, :cadastro_pessoa_fisica)
To customize the error message you need to pass a keyword as thrid arity,
example: validate_cpf(changeset, :cpf, message: "My message")
Validates the cpf format and also validates the verification digits
(the last two digits) from the changeset
Both the field and error messages can be customizeds. The field defaults
to :cpf as the function name implies, customization can be used like:
validate_cpf_strictly(changeset, :cadastro_pessoa_fisica)
The error message can be customized using a message: keyword like:
validate_cpf_strictly(changeset, :cpf, message: "My error message")