Download the PHP package esponsor/dni-validator without Composer

On this page you can find all versions of the php package esponsor/dni-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dni-validator

dni-validator

CI npm Packagist

Validators for Latin American and related national ID documents. Available as both a PHP/Laravel package and a JavaScript/TypeScript package. Both packages implement the same rules and are covered by the same shared test vectors.

Supported documents

Country Type Validation PHP class JS import
πŸ‡¦πŸ‡· Argentina CUIT/CUIL Prefix + modulo-11 check digit CuitCuilArgentina /argentina
πŸ‡§πŸ‡· Brazil CPF Two modulo-11 check digits CpfBrazil /brazil
πŸ‡§πŸ‡· Brazil CNPJ Two modulo-11 check digits CnpjBrazil /brazil
πŸ‡¨πŸ‡¦ Canada SIN Luhn check digit SinCanada /canada
πŸ‡¨πŸ‡± Chile RUT Modulo-11 check digit RutChile /chile
πŸ‡¨πŸ‡΄ Colombia CC Structural only β€” 8 or 10 digits CcColombia /colombia
πŸ‡¨πŸ‡΄ Colombia NIT Structural only β€” 10 digits, check digit not verified NitColombia /colombia
πŸ‡¨πŸ‡΄ Colombia PASS Length only β€” 2 to 12 characters PassportColombia /colombia
πŸ‡ͺπŸ‡¨ Ecuador CI Structural only β€” 10 digits, check digit not verified CiEcuador /ecuador
πŸ‡ͺπŸ‡¨ Ecuador RUT Structural only β€” 13 digits, check digit not verified RutEcuador /ecuador
πŸ‡ͺπŸ‡¨ Ecuador PASS Length only β€” 8 to 12 characters PassportEcuador /ecuador
πŸ‡ͺπŸ‡Έ Spain DNI Modulo-23 check letter (covers DNI and NIE) DniSpain /spain
πŸ‡²πŸ‡½ Mexico CURP Regex + weighted checksum CurpMexico /mexico
πŸ‡΅πŸ‡ͺ Peru DNI Structural only β€” 8 digits plus optional verification character DniPeru /peru
πŸ‡΅πŸ‡ͺ Peru RUC Structural only β€” 11 digits with a known taxpayer prefix RucPeru /peru
πŸ‡ΊπŸ‡Έ United States / πŸ‡΅πŸ‡· Puerto Rico SSN Structural only β€” rejects ranges the SSA never issues SsnUnitedStates /united-states
πŸ‡ΊπŸ‡Ύ Uruguay CI Weighted check digit CiUruguay /uruguay
πŸ‡ΊπŸ‡Ύ Uruguay RUT Modulo-11 check digit RutUruguay /uruguay

Rows marked Structural only or Length only verify shape or length, not a checksum: a well-formed value can still be a number that was never issued.


PHP

Install

Requires PHP ^8.4 and illuminate/contracts ^10|^11|^12|^13.

Direct usage

Every validator exposes validate(). Most also expose clean() (strip formatting) and format() (apply the country's display format); passport validators only expose validate(), and RutEcuador has no display format.

Laravel validation rules

Each validator has a matching rule under Esponsor\DniValidator\Rules named after the validator class (CpfBrazil β†’ CpfBrazilRule). Rules reject non-string values and fail with a Spanish message.

Registry

Country and document type are matched case insensitively.

Running PHP tests


JavaScript / TypeScript

Install

Requires Node 22+. The published npm package is the repo root package.json; packages/js holds sources and tests only.

Named imports

Import from the country subpath, or from the package root for everything at once. Function names are suffixed with the country when the same document type exists in several countries (ciUruguayValidate, ciEcuadorValidate, dniPeruValidate, dniSpainValidate).

Registry

Country and document type are matched case insensitively.

Running JS tests


Contributing

See SECURITY.md.

Shared specs

spec/<cc>/<type>.json is the language-independent contract for each document (valid, invalid with reasons, optional format_cases, and metadata). Both the PHP and JS test suites load these files through the registry, so the two runtimes cannot drift apart. See spec/README.md for the schema.

Behaviour notes

These validators were ported from the eSponsor front-end helper. The following differences are deliberate fixes:


License

MIT β€” Copyright (c) 2026 eSponsor


All versions of dni-validator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/contracts Version ^10|^11|^12|^13
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package esponsor/dni-validator contains the following files

Loading the files please wait ...