百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

axiom

> 编程语言
开源

一个包,提供可重复使用的 Laravel 验证规则库。

534 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个包,提供可重复使用的 Laravel 验证规则库。

Axiom

This package provides a library of reusable validation rules for your Laravel projects. Use them to augment the existing set provided by Laravel itself.

Installation

Pull in the package using composer

bash
composer require caneara/axiom

Upgrading

Axiom includes several breaking changes from the original package, so you'll need to follow these steps if you were using the old version:

  1. Ensure that you are using PHP 7.4 or later.
  2. Remove alphametric/laravel-validation-rules from your composer.json file.
  3. Run composer update to remove the package from your vendor directory.
  4. Install Axiom by running composer require caneara/axiom.
  5. Replace all instances of use Alphametric\Validation with use Axiom.
  6. The EndsWith rule has been removed as Laravel now natively supports this.
  7. The Equals rule has been removed. Instead, you should use Laravel's native in rule with a single option.
  8. The DoesNotExist rule has been renamed to Missing.

Usage

As per the Laravel documentation, simply import the relevant validation class wherever you require it, and then include it within the rules for a particular field:

php
use Axiom\Rules\StrongPassword;

// ...

$request->validate([
    'password' => ['bail', 'required', new StrongPassword],
]);

IMPORTANT: As with all custom rules, you cannot use a pipe-delimited string. You must instead use an array e.g.

php
'password' => ['bail', 'required', new StrongPassword] // correct
'password' => 'bail|required|new StrongPassword'       // wrong

If the validation fails, the package will attempt to respond with a localized error message (see message keys below). If the key does not exist, it will fall back to a hard-coded English language version.

Available rules

The following validation rules are currently available:

Rule Message Key Description
StrongPassword validation.strong_password Requires the presence of a "strong" password - see class for details
TelephoneNumber validation.telephone_number Requires the presence of a valid telephone number - see class for details
RecordOwner validation.record_owner Requires the authenticated user's id to match the user_id column on a given database record e.g. owner:posts,id
MonetaryFigure validation.monetary_figure Requires the presence of a monetary figure e.g $72.33 - see class for details
DisposableEmail validation.disposable_email Requires the presence of an email address which is not disposable
Missing validation.missing Requires that the given value is not present in a given database table / column - see class for details
Decimal validation.decimal Requires that the given value is a decimal with an appropriate format - see class for details
EncodedImage validation.encoded_image Requires that the given value is a base64-encoded image of a given mime types - see class for details
LocationCoordinates validation.location_coordinates Requires that the given value is a comma-separated set of latitude and longitude coordinates
FileExists validation.file_exists Requires that the given value is a path to an existing file - see class for details
MacAddress validation.mac_address Requires that the given value is a valid MAC address
ISBN validation.isbn Requires that the given value is a valid ISBN-10 or ISBN-13 number
EvenNumber validation.even_number Requires that the given value is an even number (decimals are first converted using intval)
OddNumber validation.odd_number Requires that the given value is an odd number (decimals are first converted using intval)
Lowercase validation.lowercase Requires that the given value is a lower case string
Uppercase validation.uppercase Requires that the given value is a upper case string
Titlecase validation.titlecase Requires that the given value is a title case string
Domain validation.domain Requires that the given value be a domain e.g. google.com, www.google.com
CitizenIdentification validation.citizen_identification Requires that the given value be a citizen identification number of USA, UK, France, Brazil or Vietnam (see class for details)
WithoutWhitespace validation.without_whitespace Requires that the given value not include any whitespace characters
MaxWords validation.max_words Requires that the given value cannot contain more words than specified
HexColor validation.hex_color Requires that the given value is a valid hex color eg. #fff, #0f0f0f, #00ff0080

Contributing

Thank you for considering a contribution to Axiom. You are welcome to submit a PR containing improvements, however if they are substantial in nature, please also be sure to include a test or tests.

License

The MIT License (MIT). Please see License File for more information.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHP

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言