Brian Dunning's FileMaker Custom Functions

Validate_CNPJ ( _Num )

Validates Brazilian CNPJ number

  Average rating: 4.2 (31 votes) Log in to vote

FCO   FCO
FCO

Share on Facebook Share on Twitter

  Sample input:
Validate_CNPJ ("11.222.333/0001-81")
  Sample output:
1

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Description:
In Brazil there is a CNPJ (Cadastro Nacional de Pessoas Jurídicas) number which serves to identify each legal entity (company, corporation) in the country. The number composes of fourteen numeric digits, being the two last ones the checking digits.

The function calculates the two checking digits, based on the twelve preceding digits.

Input:
the fourteen numeric digits for a CNPJ number

Output:
-3 (parameter is empty)
-2 (number of digits <> 14)
-1 (incorrect entry)
1 (OK)

Examples:
lnput: Validate_CNPJ (11222333000181)
Output: 1

lnput: Validate_CNPJ ("11.222.333/0001-81")
Output: 1

You can modify the Case result numbers to return a Boolean calculation, so that the function could be tested as GetAsBoolean ( Validate_CNPJ (_Num) ).

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: