Download the PHP package jamacio/document-validator without Composer
On this page you can find all versions of the php package jamacio/document-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jamacio/document-validator
More information about jamacio/document-validator
Files in jamacio/document-validator
Package document-validator
Short Description A PHP library for validating and formatting Brazilian CPF and CNPJ numbers.
License MIT
Homepage https://github.com/jamacio/document-validator
Informations about the package document-validator
Document Validator
Document Validator is a PHP library designed for validating and formatting Brazilian CPF and CNPJ numbers. It offers easy-to-use static methods to verify the correctness of these documents using the official algorithms, as well as to apply standard masks for displaying them.
Features
- CPF Validation: Validates Brazilian CPF numbers (11 digits) using the official algorithm.
- CNPJ Validation: Validates Brazilian CNPJ numbers (14 digits) using the official algorithm.
- Document Identification: Automatically determines if the provided number is a CPF or CNPJ based on its digit count.
- Formatting: Applies standard masks:
- CPF Format:
XXX.XXX.XXX-XX
- CNPJ Format:
XX.XXX.XXX/XXXX-XX
- CPF Format:
Requirements
- PHP 7.2 or higher
- Composer
Installation
Install Document Validator via Composer by running the following command in your terminal:
Usage
Ensure Composer's autoloader is included in your project.
Note: If you are using a CMS or framework (e.g., Laravel, Symfony), this step is usually not necessary as the autoloader is already included.
Then, use the DocumentValidator class as follows:
By including the Composer autoloader, the class will be available throughout your project without the need for manual file inclusion.