juststeveking/fluent-validation
Composer 安装命令:
composer require juststeveking/fluent-validation
包简介
Fluent Validation is a helper package, that allows you to use sensible defaults for your Laravel validation rules.`
README 文档
README
Fluent Validation is a helper package, that allows you to use sensible defaults for your Laravel validation rules.
Installation
composer require juststeveking/fluent-validation
Why??
Why did I create this package? Well to be honest, I was feeling lazy - but a productive kind of lazy. I was writing some validation for quite a large API request and looked at all the string input I was about to have to validate, and thought there must be an easier way. So I created this to save me time by taking time building a package. I got the last laugh though, as now I never have to write the same string validation again!
Usage
To use this package all you need to do is include the rules you may wish to use:
Validating emails
return [ 'email' => \JustSteveKing\FluentValidation\Fluency\EmailRule::rules() ];
Or to build them up yourself and/or override them:
return [ 'email' => [ \JustSteveKing\FluentValidation\Rules\Required::rule(), \JustSteveKing\FluentValidation\Rules\Email::rule('rfc,dns'), ] ];
Validating Passwords
return [ 'password' => \JustSteveKing\FluentValidation\Fluency\PasswordRule::rules() ];
Or to build them up yourself and/or override them:
return [ 'password' => [ \JustSteveKing\FluentValidation\Rules\Required::rule(), \Illuminate\Validation\Rules\Password::default(), ] ];
Validating Strings
return [ 'title' => \JustSteveKing\FluentValidation\Fluency\StringRule::rules() ];
Or to build them up yourself and/or override them:
return [ 'title' => [ \JustSteveKing\FluentValidation\Rules\Required::rule(), \JustSteveKing\FluentValidation\Rules\Text::rule(), \JustSteveKing\FluentValidation\Rules\Min::rule(2), \JustSteveKing\FluentValidation\Rules\Max::rule(255), ] ];
Available Fluency Rules
This is a list of the currently available Fluency Rules:
EmailRule- Will returnrequiredandemailrules.PasswordRule- Will returnrequiredandPassword::default()rules from Laravel.StringRule- Will returnrequired,min:2, andmax:255rules.
Available Rules
This is a list of the currently available Rules:
Accepted- Will returnacceptedor whatever override input you pass.After- Will returnafter:and whatever override input you pass.AfterOrEqual- Will returnafter_or_equal:and whatever override input you pass.Alpha- Will returnalphaor whatever override input you pass.Boolean- Will returnbooleanor whatever override input you pass.Date- Will returndateor whatever override input you pass.Email- Will returnemail:and whatever override input you pass.Enum- Will return a new Laravel Enum validation rule, you must pass a backed Enum to this instance usingYourEnum::class.Exists- Will returnexists:with whatever table and an optional column you pass to it.Integer- Will returnintegeror whatever override input you pass.Max- Will returnmax:and whatever override input you pass.Min- Will returnmin:and whatever override input you pass.Required- Will returnrequiredor whatever override input you pass.Text- Will returnstringor whatever override input you pass.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
juststeveking/fluent-validation 适用场景与选型建议
juststeveking/fluent-validation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 568 次下载、GitHub Stars 达 25, 最近一次更新时间为 2022 年 11 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 juststeveking/fluent-validation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 juststeveking/fluent-validation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 568
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 25
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-09