liagkos/laravel-grvatid-validator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

liagkos/laravel-grvatid-validator

Composer 安装命令:

composer require liagkos/laravel-grvatid-validator

包简介

Validator for Laravel in order to check if a number is POTENTIALLY valid in Greek VAT ID Registry

README 文档

README

The Greek VAT ID validator checks if a number is POTENTIALLY valid in Greek VAT ID Registry.

Validator does NOT check if VAT ID does actually belong to a person or a company, it checks only if it obeys the algorithm of a valid Greek VAT ID:

1. VAT ID = 090000045
2. Calculate sum of 0*2^8+9*2^7+0*2^6+0*2^5+0*2^4+0*2^3+0*2^2+4*2^1 = 1160
3. Calculate mod11 = 1160 % 11 = 5
4. Calculate mod10 = 5 % 10 = 5
5. mod10 (5) is equal to 5 (last digit), so VAT ID is VALID
1. VAT ID = 123456789
2. Calculate sum of 1*2^8+2*2^7+3*2^6+4*2^5+5*2^4+6*2^3+7*2^2+8*2^1 = 1004
3. Calculate mod11 = 1004 % 11 = 3
4. Calculate mod10 = 3 % 10 = 3
5. mod10 (3) is not equal to 9 (last digit), so VAT ID is INVALID

Installation

Install the package using Composer:

composer require liagkos/laravel-grvatid-validator

Laravel's service provider discovery will automatically configure the Grvatval service provider for you.

Using the grvatval validator

After installation, the grvatval validator will be available for use directly in your validation rules.

'vatid' => 'grvatval',

Within the context of a registration form, it would look like this:

return Validator::make($data, [
    'name' => 'required',
    'email' => 'required|string|email',
    'password' => 'required',
    'vatid' => 'required|grvatval'
]);

Using the Rule Object

Alternatively, you can use the Liagkos\Grvatval\Grvatval Validation Rule Object instead of the grvatval alias if you prefer:

return Validator::make($data, [
    'name' => 'required',
    'email' => 'required|string|email',
    'password' => 'required',
    'vatid' => ['required', new \Liagkos\Grvatval\Grvatval],
]);

Validation message

You will need to assign your own validation message within the resources/lang/*/validation.php file(s). Both the Rule object and the grvatval validator alias refer to the validation string validation.grvatval.

Testing

Just run the the test in tests directory. I use the orchestra/testbench along with PHPUnit.

Credits

Since I'm quite new in all Laravel stuff, I got the idea from Stephen Rees-Carten and his own valorin/pwned-validator validator, from whom I used some code and README.md stuff, modified accordingly to make this validator. Thank you Stephen, live long and propsper!

liagkos/laravel-grvatid-validator 适用场景与选型建议

liagkos/laravel-grvatid-validator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 liagkos/laravel-grvatid-validator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 liagkos/laravel-grvatid-validator 我们能提供哪些服务?
定制开发 / 二次开发

基于 liagkos/laravel-grvatid-validator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-04