luilliarcec / laravel-ecuador-identification
Validations for Laravel for identifications of people and companies of Ecuador, an important requirement for electronic invoicing.
Installs: 1 032
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 2
Open Issues: 1
Requires
- php: ^8.0
- laravel/framework: ^9.0
Requires (Dev)
- orchestra/testbench: ^7.0
- phpunit/phpunit: ^9.0
README
Laravel Ecuador Identification is a validation library for Laravel, which allows the validation of personal and business identification documents, according to the country's tax regulations.
It is fully adaptable to Laravel's Facade and Validator Class. Its use is also shown in a Facade identified with the name of the country. You can use it as follows.
$request->validate([ 'identification' => 'ecuador:natural_ruc', ]);
Or with Validator Facade
$validator = Validator::make($request->all(), [ 'identification' => 'ecuador:natural_ruc', ]);
Or with Ecuador Facade
use Luilliarcec\LaravelEcuadorIdentification\Facades\EcuadorIdentification; EcuadorIdentification::validateNaturalRuc('1710034065001'); // Return null or string code
Installation
You can install the package via composer:
composer require luilliarcec/laravel-ecuador-identification
Usage
When using the Laravel validator, each of them can be accessed by simply calling the validations by placing the [rule_name]:[validation_name].
Ecuador (ecuador)
For ecuador use the "ecuador" rule
Ecuador has 5 types of documents, identification person or identity card, ruc of natural persons, ruc of private companies and ruc of public companies, in addition to billing the fictitious document of final consumer is used.
Validation rules:
- Final Customer
- Personal Identification
- Natural Ruc
- Private Ruc
- Public Ruc
- Ruc
- Is Juridical Person
- Is Natural Person
- All Identifications
final_customer
Validate the final consumer document, this validation on the Facade returns your billing code
personal_identification
Validate the Ecuadorian identification card, this validation on the Facade returns your billing code
natural_ruc
Validates the Ecuadorian RUC of Natural Person, this validation on the Facade returns your billing code
private_ruc
Validates the Ecuadorian RUC of Private Companies, this validation on the Facade returns your billing code
public_ruc
Validates the Ecuadorian RUC of Public Companies, this validation on the Facade returns your billing code
ruc
Validates the Ecuadorian RUC Companies (Public, Natural and Private), this validation on the Facade returns your billing code
is_juridical_person
The group called juridical persons are those that have an private ruc or a public ruc such validation on the Facade will return the billing code if the person has one of these documents, otherwise null.
is_natural_person
The group called natural persons are those that have an Ecuadorian identity card or a natural ruc such validation on the Facade will return the billing code if the person has one of these documents, otherwise null.
all_identifications
Validate the number with all types of documents. It includes the validation of final consumer. This validation in the Facade returns the corresponding billing code, if it fails, it returns null.
Example
Validator
Validations return true or false following the laravel validation convention.
$request->validate([ 'identification' => 'ecuador:personal_identification', ]);
Facade
Facades return null if the document number does not match any type, otherwise they return the billing code.
use Luilliarcec\LaravelEcuadorIdentification\Facades\EcuadorIdentification; EcuadorIdentification::validateAllTypeIdentification('9999999999999'); // Return '07' => Final Consumer
Translations
If you like to use the translation system of Laravel to present the messages or attributes. Access the corresponding
files located in the resources\lang\{language_code}\validation
folder.
Example
resources\lang\en\validation:
return [ ... 'ecuador' => 'The :attribute field does not have the corresponding country format. (Ecuador)', /* |-------------------------------------------------------------------------- | Custom Validation Attributes |-------------------------------------------------------------------------- | | The following language lines are used to swap our attribute placeholder | with something more reader friendly such as "E-Mail Address" instead | of "email". This simply helps us make our message more expressive. | */ 'attributes' => [ 'id' => 'Ecuadorian Identification', ], ];
resources\lang\es\validation:
return [ ... 'ecuador' => 'El campo :attribute no tiene el formato de país correspondiente. (Ecuador)', /* |-------------------------------------------------------------------------- | Custom Validation Attributes |-------------------------------------------------------------------------- | | The following language lines are used to swap our attribute placeholder | with something more reader friendly such as "E-Mail Address" instead | of "email". This simply helps us make our message more expressive. | */ 'attributes' => [ 'id' => 'Identificación Ecuatoriana', ], ];
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email luilliarcec@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.