@Override public void initialize(final CPF constraintAnnotation) { // validates CPF strings with separator, eg 134.241.313-00 // there are two checksums generated. The first over the digits prior the hyphen with the first // check digit being the digit directly after the hyphen. The second checksum is over all digits // pre hyphen + first check digit. The check digit in this case is the second digit after the // hyphen this.withSeparatorMod11Validator1.initialize(0, 10, 12, true, Integer.MAX_VALUE, '0', '0', Mod11Check.ProcessingDirection.RIGHT_TO_LEFT); this.withSeparatorMod11Validator2.initialize(0, 12, 13, true, Integer.MAX_VALUE, '0', '0', Mod11Check.ProcessingDirection.RIGHT_TO_LEFT); // validates CPF strings with separator, eg 134241313-00 this.withDashOnlySeparatorMod11Validator1.initialize(0, 8, 10, true, Integer.MAX_VALUE, '0', '0', Mod11Check.ProcessingDirection.RIGHT_TO_LEFT); this.withDashOnlySeparatorMod11Validator2.initialize(0, 10, 11, true, Integer.MAX_VALUE, '0', '0', Mod11Check.ProcessingDirection.RIGHT_TO_LEFT); // validates CPF strings without separator, eg 13424131300 // checksums as described above, except there are no separator characters this.withoutSeparatorMod11Validator1.initialize(0, 8, 9, true, Integer.MAX_VALUE, '0', '0', Mod11Check.ProcessingDirection.RIGHT_TO_LEFT); this.withoutSeparatorMod11Validator2.initialize(0, 9, 10, true, Integer.MAX_VALUE, '0', '0', Mod11Check.ProcessingDirection.RIGHT_TO_LEFT); }
@NotEmpty(message = "CPF não pode ser vazio.") @CPF(message="CPF inválido") public String getCpf() { return cpf; }