RENAVAM
Registro Nacional de Veículos Automotores, the Brazilian vehicle registry number.
Validate
- JavaScript library
- Python library7 cases fail
- Go library5 cases fail
- Ruby library7 cases fail
- Rust library5 cases fail
- .NET library5 cases fail
- Erlang library7 cases fail
Validates a RENAVAM: the old format (9 digits, left-padded to 11) or the new format (11 digits), with a modulus 11 check digit.
- The function ignores spaces, dots, hyphens and slashes, alone or in a run, so every punctuated form is accepted (
0063988.4962,0063988/4962,00639884-962). Any other character, in particular a letter or an underscore, makes the value invalid. Until 2.4.0 a slash was rejected. - Check digit: the ten base digits, read from right to left, are multiplied by 2, 3, 4, 5, 6, 7, 8, 9, 2 and 3. The digit is the remainder by 11 of ten times the sum, with a remainder of 10 read as 0.
- A value whose digits are all the same is rejected.
- A number is read only when it is a safe non-negative integer. A negative or fractional number is invalid: 2.4.0 accepted
-639884962and63988496.2. Strings and non-negative integers give the same result as before. - Portaria DENATRAN nº 27/2013 gives 10 digits and a check digit "calculado através do módulo 11, peso 9". It does not write out the weights, the handling of a remainder of 0, 1 or 10, or how a 9-digit code is read as 11 digits. Those parts follow community references and market practice.
- A number loses its leading zeros, so an 11-digit RENAVAM that starts with
0is only accepted as a string:"08794266580"is valid and8794266580is not. - A value that is not a string or a number returns
false.
| Parameter | Type | Required |
|---|---|---|
renavam | string | number | yes |
| returns | boolean |
Check if a RENAVAM (Registro Nacional de Veículos Automotores) is valid. Accepts the old format (9 digits) and the new format (11 digits).
- Spaces, dots, hyphens and slashes are ignored; any other character makes the value invalid.
- A number loses its leading zeros, so an 11 digit RENAVAM that starts with
0is only accepted as a string:isValidRenavam('08794266580')istrueandisValidRenavam(8794266580)isfalse. - The check digit is the one of Portaria DENATRAN nº 27/2013, art. 1º: "10 dígitos e um dígito verificador, calculado através do módulo 11, peso 9", read as the weights 3, 2, 9, 8, 7, 6, 5, 4, 3 and 2. The portaria gives neither the weights one by one nor the handling of a remainder of 0, 1 or 10, which follow validation-br and brutils; padding a 9 digit code to 11 with zeros is market practice.
import { isValidRenavam } from '@brazilian-utils/brazilian-utils';
isValidRenavam('639884962'); // true (9 digits, old format)
isValidRenavam('00639884962'); // true (11 digits, new format)
isValidRenavam('0063988.4962'); // true (the dot is ignored)
isValidRenavam('12345678901'); // false (invalid checksum)
isValidRenavam('00000000000'); // false (repeated digits)
isValidRenavam('ab00639884962'); // false (letters are rejected)Source: Portaria DENATRAN nº 27/2013.
Code: brazilian-utils/javascriptShared test cases (39) and the result in each library renavam.isValid
Generate
Generates a valid random RENAVAM in the 11-digit form: 10 base digits plus the check digit.
| Parameter | Type | Required |
|---|---|---|
| returns | string |
Generate a valid random RENAVAM in the 11 digit form: ten base digits plus the check digit.
import { generateRenavam } from '@brazilian-utils/brazilian-utils';
generateRenavam(); // '12345678900'Shared test cases (1) and the result in each library renavam.generate
Official sources
See also License plate, VIN (chassis)
Last updated on
