vdhicts/laravel-validation-rules
Composer 安装命令:
composer require vdhicts/laravel-validation-rules
包简介
Collection of validation rules for Laravel.
README 文档
README
This package offers extra validation rules for Laravel.
Requirements
This package requires Laravel 11+ and PHP 8.2+. If you need to support older version, see the table below:
| Version | Compatible with |
|---|---|
| 9.0.0 | 13+ |
| 7.0.0 | 12+ |
| 6.0.0 | 11+ |
| 4.0.0+ | 10+ |
| 3.0.0 | 9+ |
| 1.4.0+ | 8+ |
| 1.2.0+ | 7+ |
| 1.1.0 | 6+ |
| 1.0.1 | 5.7+ |
Installation
You can install the package via composer:
composer require vdhicts/laravel-validation-rules
The package will automatically register itself in Laravel.
Translation
The package includes both English and Dutch translations. The translations can be published by running:
php artisan vendor:publish
Available Rules
BicNumber
Validates the provided BIC number.
'field' => [new BicNumber()],
Contains
Validates if the value contains a certain phrase.
'field' => [new Contains($needle)],
ContainsAny
Validates if the value contains any of the provided phrases.
'field' => [new ContainsAny(['foo', 'bar'])],
DateAfterOrEqual
Validates if the value is a date after or equals the provided date (Carbon).
'field' => [new DateAfterOrEqual($date)],
DateBeforeOrEqual
Validates if the value is a date before or equals the provided date (Carbon).
'field' => [new DateBeforeOrEqual($date)],
DateHasSpecificMinutes
Validates if the selected minutes for the provided date are according to the available minutes.
'field' => [new DateHasSpecificMinutes([0, 15, 30, 45])],
When the date is not according to the 'Y-m-d H:i' format then you are able to specify the format as second parameter:
'field' => [new DateHasSpecificMinutes([0, 15, 30, 45], 'd-m-Y H:i')],
DutchPhone
Validates if the value is a valid Dutch phone number. Both mobile or landlines are supported. See the Phone validation
rule to validate a phone number which isn't limited to the Netherlands.
'field' => [new DutchPhone()],
DutchPostalCode
Validates if the value is a valid Dutch zip code, like 1234AB.
'field' => [new DutchPostalCode()],
HostName
Validates if the value contains a valid hostname, like example.com.
'field' => [new HostName()],
InternationalBankAccountNumber
Validates if the value contains a valid IBAN.
'field' => [new InternationalBankAccountNumber()],
Interval
Validates if the value is an interval, i.e. PT30S.
'field' => [new Interval()],
MaximumHourDifference
Validates if the value is differing less then the provided amount of hours.
'field' => [new MaximumHourDifference($start, 10)];
Mime Type
Validates if the value is a structural valid MIME.
'field' => [new MimeType()],
NotContains
Validates if the value NOT contains a certain phrase.
'field' => [new NotContains($needle)],
Phone
Validates if the value is a valid phone number.
'field' => [new Phone()],
Positive interval
Validates if the value is an interval and the interval is positive.
'field' => [new PositiveInterval()],
Price
Validates if the value is a valid price. The rule optionally accepts a specific decimal sign. When the decimal isn't
provided it accepts both , or . signs.
'field' => [new Price()], // accepts both , and . 'field' => [new Price(',')], // accepts only ,
Secure url
Validates if the value is a valid secure url, i.e. is a HTTPS url.
'field' => [new SecureUrl()],
Semver
Validates if the value is a valid version according to the Semver standard.
'field' => [new Semver()],
VatNumber
Validates if the value is a properly formatted VAT number.
'field' => [new VatNumber()],
Be aware: It doesn't check if the number is known in the VAT database. If you need to know the VAT number is truly legit, check with VIES.
VersionNumber
Validates if the value is a valid version number. The rule accepts both x.y.z and x.y formats. The parameter
requirePatch allows you to require the z part of the version number. This is useful for validation PHP version
numbers for example.
'field' => [new VersionNumber(requirePatch: true)],
Contribution
Any contribution is welcome, but it should be (unit) tested and meet the PSR-12 standard and please create one pull request per feature. In exchange, you will be credited as contributor on this page.
Security
If you discover any security related issues in this or other packages of Vdhicts, please email security@vdhicts.nl instead of using the issue tracker.
License
This package is open-sourced software licensed under the MIT license.
vdhicts/laravel-validation-rules 适用场景与选型建议
vdhicts/laravel-validation-rules 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28.21k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2018 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「validation」 「rules」 「laravel」 「vdhicts」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vdhicts/laravel-validation-rules 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vdhicts/laravel-validation-rules 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vdhicts/laravel-validation-rules 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
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
Adds request-parameter validation to the SLIM 3.x PHP framework
The last validation library you will ever need!
统计信息
- 总下载量: 28.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-31