Number of characters of CPF, CNPJ and RG

10

I am doing a program that needs to validate a series of documents - CPF, CNPJ and, if possible, RG.

My questions are as follows:

  • Are there valid CNPJs with a number of characters less than 14? (eg, old companies).
    Common format: xx.xxx.xxx/xxxx-xx
    If yes, what minimum number of characters for a CNPJ to be valid?

  • Are there valid CPFs with a number of characters smaller than 11?     (eg older people)
    Common format: xxx.xxx.xxx-xx
    If yes,     what minimum number of characters for a CPF to be valid?

  • There are valid RGs with fewer (1) character numbers or     greater (2) than 9 (eg older persons (1) or children (2))
    Format     common: xx.xxx.xxx-x
    If yes, which minimum number and which number     maximum number of characters for an RG to be valid?

  • asked by anonymous 04.04.2016 / 23:21

    3 answers

    12
      

    Are there valid CNPJs with a number of characters smaller than 14? (eg, old companies)

    The format is for all national companies. One day may change, but today is always like this.

    Some systems may have to deal with foreign companies, that's quite different. But this is somewhat secondary in systems, has no basis in Brazilian operations and even systems that do international operations is essentially descriptive.

      

    Are there valid CPFs with a number of characters less than 11? (eg, the elderly)

    There is nothing different.

    What can happen is one day to change. It may be that the CPF expires one day and gives way to another document. The single document . But for now it's not a replacement.

      

    Are there valid RGs with fewer (1) or greater (2) than 9? (eg older people (1) or children (2))

    Yes, each state is one way, it may have differences between different broadcasting organs in the same state and depending on the season it may differ as well. It's hard to create a mask.

    The Internal Revenue Service has a document indicating that the maximum is 11, but it is not official , I think it has bigger.

    There are validation criteria of CNPJ and CPF. Some states have validation formulas for their General Registry (ironic name).

    In general, the RG must be left free. It seems to me that 13 or 14 is safe.

    May be useful . And about masks .

        
    11.10.2017 / 14:34
    0

    About CPF and CNPJ

    CPF 11 digits and the ninth digit refers to locality

      

    The Tax Region where the CPF (defined by the ninth digit) is issued has the   the following coverage: 1 (DF-GO-MS-MT-TO), 2 (AC-AM-AP-PA-RO-RR), 3   (BA-SE), 6 (MG), 7 (ES-RJ), 8 (SP), 9 (AL-PB-PE-RN), 5   (PR-SC) and 0 (RS)

    CNPJ 14 digits

      

    In the past, the numbers were grouped by state. Today is everything   mixed and so XX.XXX.XXX the first 8 numbers are issued   sequentially from the numbers already created. In this way, any   person with more than 10 neurons can reach the corporate CNPJ   new ones. This is how some people get their CNPJ and send   direct and fake tickets.

    Referral (and recommend reading): #

    RG is more complicated, because each state has a different format and there is a possibility that two people from different states have the same number, to validate a rg it is necessary to know the creation rule of each state.

        
    11.10.2017 / 15:03
    0

    The number of CNPJ and CPF digits are fixed, as colleagues have pointed out. The RG is complicated but @Bacco's suggestion to also use the 'Issuer' field is good. Also add the issue UF because it is not illegal for a person to have RGs issued in more than one UF. source ( [http://portalcatalao.com/cbcaixa/painel/upload/manuais/manual_caixa .pdf] )

        
    12.10.2017 / 16:07