@Override public void initialize(final CNPJ constraintAnnotation) { // validates CNPJ strings with separator, eg 91.509.901/0001-69 // 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, 14, 16, true, 9, '0', '0', Mod11Check.ProcessingDirection.RIGHT_TO_LEFT); this.withSeparatorMod11Validator2.initialize(0, 16, 17, true, 9, '0', '0', Mod11Check.ProcessingDirection.RIGHT_TO_LEFT); // validates CNPJ strings without separator, eg 91509901000169 // checksums as described above, except there are no separator characters this.withoutSeparatorMod11Validator1.initialize(0, 11, 12, true, 9, '0', '0', Mod11Check.ProcessingDirection.RIGHT_TO_LEFT); this.withoutSeparatorMod11Validator2.initialize(0, 12, 13, true, 9, '0', '0', Mod11Check.ProcessingDirection.RIGHT_TO_LEFT); }
@NotEmpty(message = "CNPJ não pode ser vazio.") @CNPJ(message="CNPJ inválido.") public String getCnpj() { return cnpj; }