luilliarcec/laravel-ecuador-identification

Laravel的厄瓜多尔个人和企业识别验证,这是电子发票的重要要求。

3.0.0 2022-06-21 01:32 UTC

This package is auto-updated.

Last update: 2024-09-24 16:09:31 UTC


README

Run Tests Latest Version on Packagist Quality Score Total Downloads GitHub license

Laravel Ecuador Identification 是一个用于 Laravel 的验证库,允许根据国家税务规定验证个人和商业识别文件。

它完全适用于 Laravel 的 Facade 和 Validator 类。其使用也体现在以国家名称命名的 Facade 中。您可以使用以下方式。

$request->validate([
    'identification' => 'ecuador:natural_ruc',
]);

或者使用 Validator Facade

$validator = Validator::make($request->all(), [
    'identification' => 'ecuador:natural_ruc',
]);

或者使用 Ecuador Facade

use Luilliarcec\LaravelEcuadorIdentification\Facades\EcuadorIdentification;

EcuadorIdentification::validateNaturalRuc('1710034065001'); // Return null or string code

安装

您可以通过 composer 安装此包。

composer require luilliarcec/laravel-ecuador-identification

用法

当使用 Laravel 验证器时,可以通过简单地调用规则来访问每个规则,格式为 [rule_name]:[validation_name]。

厄瓜多尔 (ecuador)

对于厄瓜多尔,使用 "ecuador" 规则

厄瓜多尔有5种文件类型,包括身份证或身份证、自然人RUC、私人公司RUC和公共公司RUC,此外,还使用最终消费者虚构文档进行开票。

验证规则

final_customer

验证最终消费者文件,此 Facade 上的验证返回您的发票代码

personal_identification

验证厄瓜多尔身份证,此 Facade 上的验证返回您的发票代码

natural_ruc

验证厄瓜多尔自然人RUC,此 Facade 上的验证返回您的发票代码

private_ruc

验证厄瓜多尔私人公司RUC,此 Facade 上的验证返回您的发票代码

public_ruc

验证厄瓜多尔公共公司RUC,此 Facade 上的验证返回您的发票代码

ruc

验证厄瓜多尔公司RUC(公共、自然和私人),此 Facade 上的验证返回您的发票代码

is_juridical_person

称为法人实体的组是指那些具有私人RUC或公共RUC的人,此 Facade 上的验证将返回发票代码,如果该人拥有这些文件之一,否则返回null。

is_natural_person

称为自然人的组是指那些拥有厄瓜多尔身份证或自然人RUC的人,此 Facade 上的验证将返回发票代码,如果该人拥有这些文件之一,否则返回null。

all_identifications

验证所有类型的文件号码。包括最终消费者的验证。此 Facade 上的验证返回相应的发票代码,如果验证失败,则返回null。

示例

验证器

验证返回 true 或 false,遵循 Laravel 验证惯例。

$request->validate([
    'identification' => 'ecuador:personal_identification',
]);

外观

外观返回 null,如果文档号码不匹配任何类型,否则返回发票代码。

use Luilliarcec\LaravelEcuadorIdentification\Facades\EcuadorIdentification;

EcuadorIdentification::validateAllTypeIdentification('9999999999999'); // Return '07' => Final Consumer

翻译

如果您想使用 Laravel 的翻译系统来显示消息或属性,请访问位于 resources\lang\{language_code}\validation 文件夹中的相应文件。

示例

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

测试

composer test

更新日志

请参阅变更日志以获取更多关于最近更改的信息。

贡献

请参阅贡献指南以获取详细信息。

安全性

如果您发现任何与安全相关的问题,请通过电子邮件luilliarcec@gmail.com联系,而不是使用问题跟踪器。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。

Laravel 包模板

本包使用Laravel 包模板生成。