Skip to content

[cpf-gen] Throw error on repeated digits input #25

@juliolmuller

Description

@juliolmuller

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions