Title: | Validate, Compare and Format Identification Numbers from Brazil |
---|---|
Description: | Validate, format and compare identification numbers used in Brazil. These numbers are used to identify individuals (CPF), vehicles (RENAVAN), companies (CNPJ) and etc. Functions to format, validate and compare these numbers have been implemented in a vectorized way in order to speed up validations and comparisons in big datasets. |
Authors: | Wilson Freitas [aut, cre] |
Maintainer: | Wilson Freitas <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.2 |
Built: | 2024-11-04 04:18:59 UTC |
Source: | https://github.com/wilsonfreitas/numbersbr |
Compares the brazilian numbers among themselves, with numeric and character objects.
## S3 method for class 'CNPJ' e1 == e2 ## S3 method for class 'CNPJ' e1 != e2 ## S3 method for class 'CPF' e1 == e2 ## S3 method for class 'CPF' e1 != e2 ## S3 method for class 'RENAVAN' e1 == e2 ## S3 method for class 'RENAVAN' e1 != e2
## S3 method for class 'CNPJ' e1 == e2 ## S3 method for class 'CNPJ' e1 != e2 ## S3 method for class 'CPF' e1 == e2 ## S3 method for class 'CPF' e1 != e2 ## S3 method for class 'RENAVAN' e1 == e2 ## S3 method for class 'RENAVAN' e1 != e2
e1 |
the identification number class. |
e2 |
the object to be compared with, can be of the same type of |
A logical vector indicating that the given objects represent the same number.
x <- CNPJ(13515463000138) x == '13515463000138' x <- CPF(68194359406) x != "681.943.594-06" x <- RENAVAN(68194359406) x == "68194359406"
x <- CNPJ(13515463000138) x == '13515463000138' x <- CPF(68194359406) x != "681.943.594-06" x <- RENAVAN(68194359406) x == "68194359406"
The brazilian numbers used to identify individuals, vehicles, companies and any other things have their own S3 classes.
CNPJ(x) CPF(x) RENAVAN(x)
CNPJ(x) CPF(x) RENAVAN(x)
x |
the identification number as numeric or character |
A S3 class representing the brazilian number: CNPJ, CPF, RENAVAN
CNPJ(c(13515463000138, 3737211000108, 360305000104, 66670000100)) CNPJ(c("13.515.463/0001-38", "03.737.211/0001-08", "00.360.305/0001-04", "00.066.670/0001-00")) CPF(c(68194359406, 1239157673, 52008275582)) CPF(c("681.943.594-06", "012.391.576-73", "520.082.755-82")) RENAVAN(c(75320797785, 91671999129, 60885589380))
CNPJ(c(13515463000138, 3737211000108, 360305000104, 66670000100)) CNPJ(c("13.515.463/0001-38", "03.737.211/0001-08", "00.360.305/0001-04", "00.066.670/0001-00")) CPF(c(68194359406, 1239157673, 52008275582)) CPF(c("681.943.594-06", "012.391.576-73", "520.082.755-82")) RENAVAN(c(75320797785, 91671999129, 60885589380))
Formats the brazilian numbers according to their specific format.
## S3 method for class 'CNPJ' format(x, format = c("strict", "stripped"), ...) ## S3 method for class 'CPF' format(x, format = c("strict", "stripped"), ...) ## S3 method for class 'RENAVAN' format(x, ...)
## S3 method for class 'CNPJ' format(x, format = c("strict", "stripped"), ...) ## S3 method for class 'CPF' format(x, format = c("strict", "stripped"), ...) ## S3 method for class 'RENAVAN' format(x, ...)
x |
the identification number class. |
format |
can be strict which is the default format with all dots, dashes and hyphens or stripped which returns only the numbers. |
... |
arguments to be passed to or from other methods. |
A character vector with the formatted number.
x <- CNPJ(66670000100) format(x) format(x, "stripped") x <- CPF(1239157673) format(x) format(x, "stripped") x <- RENAVAN("68194359406") format(x)
x <- CNPJ(66670000100) format(x) format(x, "stripped") x <- CPF(1239157673) format(x) format(x, "stripped") x <- RENAVAN("68194359406") format(x)
Validates the brazilian numbers when it is necessary. Not all identification numbers don't have a validation algorithm.
is.valid(x) ## S3 method for class 'CNPJ' is.valid(x) ## S3 method for class 'CPF' is.valid(x) ## S3 method for class 'RENAVAN' is.valid(x)
is.valid(x) ## S3 method for class 'CNPJ' is.valid(x) ## S3 method for class 'CPF' is.valid(x) ## S3 method for class 'RENAVAN' is.valid(x)
x |
the identification number class. |
A logical vector indicating whether the number is valid or not.
is.valid(CNPJ(c(13515463000138, 66670000101))) # TRUE, FALSE is.valid(CPF(c(1239157673, 42752486198))) # TRUE, FALSE is.valid(RENAVAN(c(75320797785, 42752486198))) # TRUE, FALSE
is.valid(CNPJ(c(13515463000138, 66670000101))) # TRUE, FALSE is.valid(CPF(c(1239157673, 42752486198))) # TRUE, FALSE is.valid(RENAVAN(c(75320797785, 42752486198))) # TRUE, FALSE
This package helps handling identification numbers used in Brazil. These numbers are used to identify individuals (CPF), vehicles (RENAVAN), companies (CNPJ) and etc. Functions to format, validate and compare these numbers have been implemented in a vectorized way in order to speed up validations and comparisons in big datasets.
Wilson Freitas