Skip to content
Validator for Uruguayan ID
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fixed ci_validation May 15, 2019
tests
.gitignore
LICENSE
README.md Update README.md May 15, 2019
composer.json
composer.lock
example.php

README.md

ci_php

Validator for Uruguayan ID

This library is a porting of https://github.com/picandocodigo/ci_js for PHP

Usage

Install it via composer:

composer require leewayweb/ci_php

Include it in your project

<?php

require_once 'vendor/autoload.php';

use Leewayweb\CiValidator\CiValidator;

$validator = new CiValidator();

Methods available

validate_ci

Takes a CI as a string and returns a boolean indicating the validity of the ID.

Example:

<?php

require_once 'vendor/autoload.php';

use Leewayweb\CiValidator\CiValidator;

$validator = new CiValidator();

echo "Validation for '1.111.111': ".($validator->validate_ci( '1.111.111' ) ? 'true' : 'false').PHP_EOL;

validation_digit

Takes a CI as a string and returns an integer (the validation digit for the given CI).

Example:

<?php

require_once 'vendor/autoload.php';

use Leewayweb\CiValidator\CiValidator;

$validator = new CiValidator();

echo "Validation digit for '1.111.111': ".$validator->validation_digit( '1.111.111' ).PHP_EOL;

random_ci

Returns a randomly (but valid) generated CI.

Example:

<?php

require_once 'vendor/autoload.php';

use Leewayweb\CiValidator\CiValidator;

$validator = new CiValidator();

echo "Random ci: ".$validator->random_ci().PHP_EOL;`
You can’t perform that action at this time.