承接 intervention/validation 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

intervention/validation

Composer 安装命令:

composer require intervention/validation

包简介

Additional validation rules for the Laravel framework

README 文档

README

Intervention Validation is an extension library for Laravel's own validation system. The package adds rules to validate data like IBAN, BIC, ISBN, creditcard numbers and more.

Latest Version Tests Monthly Downloads Support me on Ko-fi

Installation

You can install this package quick and easy with Composer.

Require the package via Composer:

$ composer require intervention/validation

Laravel integration

The Validation library is built to work with the Laravel Framework (>=10). It comes with a service provider, which will be discovered automatically and registers the validation rules into your installation. The package provides 37 additional validation rules including multi language error messages, which can be used like Laravel's own validation rules.

use Illuminate\Support\Facades\Validator;
use Intervention\Validation\Rules\Creditcard;
use Intervention\Validation\Rules\Hexadecimalcolor;
use Intervention\Validation\Rules\Username;

$validator = Validator::make($request->all(), [
    'color' => new Hexadecimalcolor([3, 6]), // pass rule as object
    'number' => ['required', 'creditcard'], // or pass rule as string
    'name' => 'required|min:3|max:20|username', // combining rules works as well
]);

Changing the error messages:

Add the corresponding key to /resources/lang/<language>/validation.php like this:

// example
'iban' => 'Please enter IBAN number!',

Or add your custom messages directly to the validator like described in the docs.

Available Rules

The following validation rules are available with this package.

Austrian insurance Number (austrian social security number)

The field under validation must be an Austrian insurance number

public Intervention\Validation\Rules\AustrianInsuranceNumber::__construct()

Base64 encoded string

The field under validation must be Base64 encoded.

public Intervention\Validation\Rules\Base64::__construct()

Business Identifier Code (BIC)

Checks for a valid Business Identifier Code (BIC).

public Intervention\Validation\Rules\Bic::__construct()

Camel case string

The field under validation must be a formatted in Camel case.

public Intervention\Validation\Rules\Camelcase::__construct()

Classless Inter-Domain Routing (CIDR)

Check if the value is a Classless Inter-Domain Routing notation (CIDR).

public Intervention\Validation\Rules\Cidr::__construct()

Creditcard Number

The field under validation must be a valid creditcard number.

public Intervention\Validation\Rules\Creditcard::__construct()

Data URI scheme

The field under validation must be a valid Data URI.

public Intervention\Validation\Rules\DataUri::__construct(?array $media_types = null)

Domain name

The field under validation must be a well formed domainname.

public Intervention\Validation\Rules\Domainname::__construct()

European Article Number (EAN)

Checks for a valid European Article Number.

public Intervention\Validation\Rules\Ean::__construct(array $lengths = [8, 13])

Parameters

length

Optional integer length (8 or 13) to check only for EAN-8 or EAN-13.

Global Release Identifier (GRid)

The field under validation must be a Global Release Identifier.

public Intervention\Validation\Rules\Grid::__construct()

Global Trade Item Number (GTIN)

Checks for a valid Global Trade Item Number.

public Intervention\Validation\Rules\Gtin::__construct(array $lengths = [8, 12, 13, 14])

Parameters

length

Optional array of allowed lengths to check only for certain types (GTIN-8, GTIN-12, GTIN-13 or GTIN-14).

Hexadecimal color code

The field under validation must be a valid hexadecimal color code.

public Intervention\Validation\Rules\Hexadecimalcolor::__construct(array $lengths = [3, 4, 6, 8])

Parameters

length

Optional length as integer to check only for shorthand (3 or 4 characters) or full hexadecimal (6 or 8 characters) form.

HSL Color

The field under validation must be a valid HSL color code.

public Intervention\Validation\Rules\Hslcolor::__construct()

HSV Color

The field under validation must be a valid HSV/HSB color code.

public Intervention\Validation\Rules\Hsvcolor::__construct()

Text without HTML

The field under validation must be free of any html code.

public Intervention\Validation\Rules\HtmlClean::__construct()

International Bank Account Number (IBAN)

Checks for a valid International Bank Account Number (IBAN).

public Intervention\Validation\Rules\Iban::__construct()

International Mobile Equipment Identity (IMEI)

The field under validation must be a International Mobile Equipment Identity (IMEI).

public Intervention\Validation\Rules\Imei::__construct()

International Standard Book Number (ISBN)

The field under validation must be a valid International Standard Book Number (ISBN).

public Intervention\Validation\Rules\Isbn::__construct(array $lengths = [10, 13])

Parameters

length

Optional length parameter as integer to check only for ISBN-10 or ISBN-13.

International Securities Identification Number (ISIN)

Checks for a valid International Securities Identification Number (ISIN).

public Intervention\Validation\Rules\Isin::__construct()

International Standard Recording Code (ISRC)

The field under validation must be a valid International Standard Recording Code (ISRC).

public Intervention\Validation\Rules\Isrc::__construct()

International Standard Serial Number (ISSN)

Checks for a valid International Standard Serial Number (ISSN).

public Intervention\Validation\Rules\Issn::__construct()

JSON Web Token (JWT)

The given value must be a in format of a JSON Web Token.

public Intervention\Validation\Rules\Jwt::__construct()

Kebab case string

The given value must be formatted in Kebab case.

public Intervention\Validation\Rules\Kebabcase::__construct()

Latitude

Checks for a valid geographic Latitude.

public Intervention\Validation\Rules\Latitude::__construct()

Longitude

Checks for a valid geographic Longitude.

public Intervention\Validation\Rules\Longitude::__construct()

LatLng

Checks for a valid geographic comma separated pair of a Latitude and a Longitude.

public Intervention\Validation\Rules\LatLng::__construct()

Lower case string

The given value must be all lower case letters.

public Intervention\Validation\Rules\Lowercase::__construct()

Luhn algorithm

The given value must verify against its included Luhn algorithm check digit.

public Intervention\Validation\Rules\Luhn::__construct()

Media (MIME) type

Checks for a valid Mime Type (Media type).

public Intervention\Validation\Rules\MimeType::__construct()

Postal Code

The field under validation must be a postal code of the given country.

public Intervention\Validation\Rules\Postalcode::__construct(array $countrycodes = [])

Parameters

countrycode

Country code in ISO-639-1 format.

Postal Code (static instantiation)

public static Intervention\Validation\Rules\Postalcode::countrycode(array $countrycodes): Postalcode

Parameters

countrycode

Country code in ISO-639-1 format.

Postal Code (static instantiation with reference)

public static Intervention\Validation\Rules\Postalcode::reference(string $reference): Postalcode

Parameters

reference

Reference key to get ISO-639-1 country code from other data in validator.

Semantic Version Number

The field under validation must be a valid version numbers using Semantic Versioning.

public Intervention\Validation\Rules\SemVer::__construct()

SEO-friendly short text (Slug)

The field under validation must be a user- and SEO-friendly short text.

public Intervention\Validation\Rules\Slug::__construct()

Snake case string

The field under validation must formatted as Snake case text.

public Intervention\Validation\Rules\Snakecase::__construct()

Title case string

The field under validation must formatted in Title case.

public Intervention\Validation\Rules\Titlecase::__construct()

Universally Unique Lexicographically Sortable Identifier (ULID)

The field under validation must be a valid Universally Unique Lexicographically Sortable Identifier.

public Intervention\Validation\Rules\Ulid::__construct()

Upper case string

The field under validation must be all upper case.

public Intervention\Validation\Rules\Uppercase::__construct()

Username

The field under validation must be a valid username. Consisting of alpha-numeric characters, underscores, minus and starting with a alphabetic character. Multiple underscore and minus chars are not allowed. Underscore and minus chars are not allowed at the beginning or end.

public Intervention\Validation\Rules\Username::__construct()

VIN (Vehicle Identification Number)

The field under validation must be a valid Vehicle identification number according to ISO-3779.

public Intervention\Validation\Rules\Vin::__construct(bool $checkDigit = false)

Parameters

checkDigit

Optional verification according to the North American check system. Default false.

Country Code (ISO 3166-1)

The field under validation must be a valid country code according to ISO 3166-1.

public Intervention\Validation\Rules\CountryCode::__construct(string $format = CountryCode::ALPHA2, bool $strict = true)

Parameters

format

The country code has three different formats ALPHA2, ALPHA3 or NUMERIC. Select the format you want to check. Default CountryCode::ALPHA2.

strict

If strict is true, the language code must be passed in uppercase. Otherwise, the case doesn't matter.

Language Code (ISO 639-1)

The field under validation must be a valid language code according to ISO ISO 639-1.

public Intervention\Validation\Rules\LanguageCode::__construct(bool $strict = true)

Parameters

strict

If strict is true, the language code must be passed in lowercase. Otherwise, the case doesn't matter.

Currency Code (ISO 4217)

The field under validation must be a valid currency code according to ISO 4217.

public Intervention\Validation\Rules\CurrencyCode::__construct(string $format = CurrencyCode::ALPHA, bool $strict = true)

Parameters

format

The currency code has two different formats ALPHA or NUMERIC. Select the format you want to check. Default CurrencyCode::ALPHA.

strict

If strict is true, the code must be passed in uppercase. Otherwise, the case doesn't matter.

Language Tag (BCP 47)

The field under validation must be a valid IETF language tag according to BCP 47 standard.

public Intervention\Validation\Rules\LanguageTag::__construct(string $delimiter = '-', bool $allowScript = false, bool $allowRegion = true, bool $allowVariants = false, bool $allowExtensions = false, bool $allowPrivateUse = false, bool $strict = true)

Parameters

delimiter

Define the delimiter used for validation. Default -.

allowScript

Specify whether the script subtag is allowed during validation. Default false.

allowRegion

Specify whether the region subtag is allowed during validation. Default true.

allowVariants

Specify whether variant subtags are allowed during validation. Default false.

allowExtensions

Specify whether extension subtags are allowed during validation. Default false.

allowPrivateUse

Specify whether private use subtags are allowed during validation. Default false.

strict

If strict is true, the subtags must be in the correct case. Otherwise, the case doesn't matter. Default true.

Development & Testing

With this package comes a Docker image to build a test suite container. To build this container you have to have Docker installed on your system. You can run all tests with this command.

$ docker-compose run --rm --build tests

Authors

This library is developed and maintained by Oliver Vogel

Thanks to the community of contributors who have helped to improve this project.

License

Intervention Validation is licensed under the MIT License.

intervention/validation 适用场景与选型建议

intervention/validation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.29M 次下载、GitHub Stars 达 677, 最近一次更新时间为 2013 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「validator」 「validation」 「base64」 「laravel」 「IBAN」 「BIC」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 intervention/validation 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 7.29M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 682
  • 点击次数: 41
  • 依赖项目数: 9
  • 推荐数: 0

GitHub 信息

  • Stars: 677
  • Watchers: 10
  • Forks: 68
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-01-22