Repeated numbers in a CPF is considered invalid, although the calculated check digits indicate it is valid. CPF sequences 111.111.111-11, 222.222.222-22, 333.333.333-33, etc, should be evaluated and denied as valid ones.
Therefore, there are 2 cases that must be handled in cpf-gen package:
- If a 9-digits
prefix is provided to CpfGenerator::generate or cpf_gen helper function, it should validate if the input has repeated numbers and throw a runtime error.
- If a sequence of repeated numbers are generated by accident, with or without a provided less-than-9-digits
prefix argument, it should rerun the digits generation to avoid invalid outputs.
Unit tests on these two scenarios are required.
Repeated numbers in a CPF is considered invalid, although the calculated check digits indicate it is valid. CPF sequences
111.111.111-11,222.222.222-22,333.333.333-33, etc, should be evaluated and denied as valid ones.Therefore, there are 2 cases that must be handled in
cpf-genpackage:prefixis provided toCpfGenerator::generateorcpf_genhelper function, it should validate if the input has repeated numbers and throw a runtime error.prefixargument, it should rerun the digits generation to avoid invalid outputs.