Laravel validation rules for Ecuadorian identification numbers. Easily validate:
- Cédula (Ecuadorian ID card)
- RUC for natural persons
- RUC for private companies
- RUC for public companies
- PHP 8.2 or higher
- Laravel 11.x or 12.x
This package depends on ec-validador-cedula-ruc. If you want to learn more about the validation logic, you can read the article How to validate Cédula and RUC in Ecuador (Spanish), which details the manual process.
composer require tavo1987/laravel-ec-validatorThe service provider is auto-discovered by Laravel. No manual registration required.
If you have disabled auto-discovery, add the service provider to your config/app.php:
'providers' => [
Tavo\EcLaravelValidator\EcValidatorServiceProvider::class,
];Use the custom validation rules in your validation logic:
// Validate Cédula (ID card)
$this->validate($request, [
'cedula' => 'ecuador:ci',
]);
// Validate RUC for natural person
$this->validate($request, [
'ruc' => 'ecuador:ruc',
]);
// Validate RUC for public company
$this->validate($request, [
'ruc' => 'ecuador:ruc_spub',
]);
// Validate RUC for private company
$this->validate($request, [
'ruc' => 'ecuador:ruc_spriv',
]);| Rule | Description |
|---|---|
ecuador:ci |
Validates Ecuadorian Cédula (10 digits) |
ecuador:ruc |
Validates RUC for natural persons (13 digits) |
ecuador:ruc_spub |
Validates RUC for public companies (13 digits) |
ecuador:ruc_spriv |
Validates RUC for private companies (13 digits) |
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreClientRequest extends FormRequest
{
public function rules(): array
{
return [
'cedula' => ['required', 'ecuador:ci'],
'ruc' => ['nullable', 'ecuador:ruc'],
];
}
}- Updated
ec-validador-cedula-ructo v2.0.1 - Fixed validation for private company RUCs (
ruc_spriv) with 7-digit extended sequential numbers - Per SRI rules, RUCs exceeding 999999 in sequential value no longer require modulo 11 check digit validation
- PHP 8.2+ required (dropped PHP 7.x support)
- Laravel 11/12 only (dropped Laravel 7.x-10.x support)
- Internal method names updated to English API (transparent to users)
| Requirement | v1.x/v2.x | v3.0 |
|---|---|---|
| PHP | ^7.2.5 | ^8.2 |
| Laravel | ^7.4.0 | ^11.0 | ^12.0 |
- PHP 8.2+ typed properties and return types
- PHPUnit 11 with
#[Test]attributes - GitHub Actions CI for PHP 8.2, 8.3, 8.4
- Updated to
ec-validador-cedula-rucv2.0 with English API
Update your composer.json:
composer require tavo1987/laravel-ec-validator:^3.0The validation rules (ecuador:ci, ecuador:ruc, etc.) remain unchanged.
The package includes a PHPUnit test suite:
./vendor/bin/phpunitIf you find a bug or want to add functionality, please feel free to open an issue or submit a pull request. Contributions must follow these rules:
- All tests must pass
- New functionality must include tests
Edwin Ramírez
- Twitter: @edwin_tavo
Bryan Suárez
- Twitter: @BryanSC_7
This package is open-sourced software licensed under the MIT license.