wemersonrv/laravel-custom-rules
Composer 安装命令:
composer require wemersonrv/laravel-custom-rules
包简介
Custom validator rules to laravel 5.5+
关键字:
README 文档
README
Custom validator rules for Laravel 5.5+.
This package contains custom validator rules for laravel 5.5+, made first for my personal use; so it's grwoing damn slowly 😫! If you don't find anything useful, please tell me or make a PR.
Important: This project was made thinking in package autodiscover, so it needs at least version 5.5+ of Laravel Framework
Installation
composer require wemersonrv/laravel-custom-rules
Usage
Use it with laravel validator rules in the way you most like: Custom Request, \Validator facade, etc.
$rules = [ 'cpf' => 'required,cpf', 'cnpj' => 'required,cnpj', 'cellphone' => 'mobile_br', 'landline' => 'landline_br', 'postal_code' => 'cep', 'mac' => 'required|mac_address', ]; $errorMsgs = [ 'cpf' => 'The :attribute must be a valid Brazilian CPF.', 'cnpj' => 'The :attribute must be a valid Brazilian CNPJ.', 'mobile_br' => 'Invalid mobile number.', // The show is yours, do as you want! 'landline_br' => 'Invalid landline number.', 'cep' => 'The :attribute must be a valid Brazilian ZIP Code (CEP).', 'mac_address' => 'The :attribute must be a valid MAC address', ]; $validator = \Validator::make($request->all(), $rules, $errorMsgs); if($validator->fails()){ return response($validator->errors(), 400); }
To-do List
- Brazilian CPF
- Brazilian CNPJ
- Brazilian Mobile phone with 9 digit
- Brazilian ZIP code (CEP)
- Brazilian Landline phone
- Brazilian states (UF)
- Mac Address
Release History
- 0.6.2
- BUGFIX: Fix CNPJ digits check
- CHANGE: Fix digit calculation, force 0 when rest result is 10
- 0.6.1
- BUGFIX: Fix CPF digits check
- CHANGE: Fix digit calculation, force 0 when rest result is 10
- 0.6.0
- Macc Address
- ADD: Mac Address rule (
mac_address)
- 0.5.0
- Brazilian Landline number
- ADD: Brazilian Landline rule (
landline_br)
- 0.4.0
- Brazilian ZIP Code (CEP)
- ADD: Brazilian Postal Code (
cep)
- 0.3.1
- Sanitize value before validation
- CHANGE: Extract only digits (without mask chars) to validate
- 0.3.0
- Brazilian CNPJ
- ADD: Brazilian CNPJ rule (
cnpj)
- 0.2.0
- Brazilian Mobile (with 9 digit check)
- ADD: Brazilian Mobile rule (
mobile_br)
- 0.1.1
- BUGFIX: Just Service provider requires, bu changing namespace
- CHANGE: From
use Rules\Cpftouse Wemersonrv\CustomRules\Rules\Cpf
- 0.1.0
- The first proper release
- ADD: Brazilian CPF rule (
cpf)
- 0.0.1
- Work in progress
References
- Laravel Framework
Meta
Wemerson Guimarães – @WemersonCG – wemersonrv@gmail.com
Distributed under the GPLv3 license. See LICENSE.md for more information.
wemersonrv/laravel-custom-rules 适用场景与选型建议
wemersonrv/laravel-custom-rules 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 257 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 05 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「validator」 「rules」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wemersonrv/laravel-custom-rules 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wemersonrv/laravel-custom-rules 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wemersonrv/laravel-custom-rules 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Runn Me! Validation and Sanitization Library
Extension for Opis JSON Schema
Magento 2 module which adds support for Speculation Rules API for instant page loads.
The coding standard applying to all Youdot PHP projects, based on Doctrine set of PHPCS rules, with additional checks.
Business rules engine tools.
A set of Laravel validation rules
统计信息
- 总下载量: 257
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2019-05-17