PHPackages                             tavo1987/laravel-ec-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. tavo1987/laravel-ec-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

tavo1987/laravel-ec-validator
=============================

Laravel validation rules for Ecuadorian identification numbers (Cédula and RUC)

v3.0.1(4mo ago)63.2k1MITPHPPHP ^8.2CI failing

Since Jun 2Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tavo1987/ec-laravel-validator)[ Packagist](https://packagist.org/packages/tavo1987/laravel-ec-validator)[ RSS](/packages/tavo1987-laravel-ec-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (9)Used By (0)

Laravel Ecuador Validator
=========================

[](#laravel-ecuador-validator)

[![Tests](https://github.com/tavo1987/ec-laravel-validator/actions/workflows/tests.yml/badge.svg)](https://github.com/tavo1987/ec-laravel-validator/actions/workflows/tests.yml)[![Latest Stable Version](https://camo.githubusercontent.com/894047a6c4ac5d09200af90e4a1c23d534f405b25bfb396408c5eb64acd7aff3/68747470733a2f2f706f7365722e707567782e6f72672f7461766f313938372f6c61726176656c2d65632d76616c696461746f722f762f737461626c65)](https://packagist.org/packages/tavo1987/laravel-ec-validator)[![Total Downloads](https://camo.githubusercontent.com/91162f7d7997ac227a8fdfd8443b87428f8348563b82d00f000b7599ad87801a/68747470733a2f2f706f7365722e707567782e6f72672f7461766f313938372f6c61726176656c2d65632d76616c696461746f722f646f776e6c6f616473)](https://packagist.org/packages/tavo1987/laravel-ec-validator)[![License](https://camo.githubusercontent.com/7123c32787e013be5a8a13598ad01f562754637ed6141e89b02e85bf16d3e63e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tavo1987/laravel-ec-validator)

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

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 11.x or 12.x

Introduction
------------

[](#introduction)

This package depends on [ec-validador-cedula-ruc](https://github.com/tavo1987/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](https://medium.com/@bryansuarez/c%C3%B3mo-validar-c%C3%A9dula-y-ruc-en-ecuador-b62c5666186f) (Spanish), which details the manual process.

Installation
------------

[](#installation)

```
composer require tavo1987/laravel-ec-validator
```

The service provider is auto-discovered by Laravel. No manual registration required.

### Manual Registration (Optional)

[](#manual-registration-optional)

If you have disabled auto-discovery, add the service provider to your `config/app.php`:

```
'providers' => [
    Tavo\EcLaravelValidator\EcValidatorServiceProvider::class,
];
```

Usage
-----

[](#usage)

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',
]);
```

### Available Rules

[](#available-rules)

RuleDescription`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)### Using with Form Requests

[](#using-with-form-requests)

```
