mahdiidea / validation
此包已废弃且不再维护。未建议替代包。
波斯语 Laravel 验证
0.4
2021-01-01 16:27 UTC
This package is auto-updated.
Last update: 2023-12-29 03:21:45 UTC
README
Laravel 波斯语验证提供了对波斯语字母、数字等的验证。
要求
- Laravel 5.*
- PHP 5.5 >=
许可证
Laravel 波斯语验证是开源软件,受MIT许可证许可。
安装
通过 Composer
$ composer require mahdiidea/validation
配置
将以下提供者添加到 config/app.php 的 providers 部分
MahdiIDea\Validation\PersianValidationServiceProvider::class,
vendor:publish
您可以通过运行 vendor:publish 命令来在此路径(resources/lang/validation)上拥有包的定制语言文件。
使用方法
您可以通过传递以下表中的 rules 键来访问验证规则
规则 | 描述 |
---|---|
persian_alpha | 波斯语字母 |
persian_num | 波斯语数字 |
persian_alpha_num | 波斯语字母和数字 |
iran_mobile | 伊朗手机号码 |
sheba | 伊朗 Sheba 号码 |
melli_code | 伊朗 melli 代码 |
is_not_persian | 不接受波斯语字母和数字 |
limited_array | 检查变量是否为数组,并且数组必须小于等于参数 |
unsigned_num | 检查变量是否为无符号数字 |
alpha_space | 接受波斯语、英语和 ... 字母,空格字符 |
a_url | 检查正确的 URL |
a_domain | 检查正确的域名 |
more | 检查值是否大于且不等于 |
less | 检查值是否小于且不等于 |
iran_phone | 伊朗电话号码 |
card_number | 付款卡号 |
address | 接受波斯语、英语和 ... 字母,波斯语和英语数字以及一些特殊字符 |
iran_postal_code | 伊朗邮政编码 |
package_name | 检查 APK 包名 |
波斯语字母
接受根据标准波斯语的语言字母,这是您可以使用此验证规则的方式
$input = [ 'فارسی' ];
$rules = [ 'persian_alpha' ];
Validator::make( $input, $rules );
波斯语数字
验证波斯语标准数字(۰۱۲۳۴۵۶۷۸۹)
$input = [ '۰۱۲۳۴۵۶۷۸۹' ];
$rules = [ 'persian_num' ];
Validator::make( $input, $rules );
波斯语字母数字
验证波斯语字母数字
$input = [ 'فارسی۱۲۳۴۵۶۷۸۹' ];
$rules = [ 'persian_alpha_num' ];
Validator::make( $input, $rules );
伊朗手机电话
验证伊朗手机电话(irancel, rightel, hamrah-e-aval, ...)
$input = [ '09381234567' ];
$rules = [ 'iran_mobile' ];
Validator::make( $input, $rules );
Sheba 号码
验证伊朗银行 Sheba 号码
$input = [ 'IR062960000000100324200001' ];
$rules = [ 'sheba' ];
Validator::make( $input, $rules );
伊朗国家代码
验证伊朗国家代码(melli-code)
$input = [ '3240175800' ];
$rules = [ 'melli_code' ];
Validator::make( $input, $rules );
付款卡号
验证伊朗付款卡号
$input = [ '6274129005473742' ];
$rules = [ 'card_number' ];
Validator::make( $input, $rules );
伊朗邮政编码
验证伊朗邮政编码
$input = [ '167197-35744' ];
$rules = [ 'iran_postal_code' ];
Validator::make( $input, $rules );
$input = [ '16719735744' ];
$rules = [ 'iran_postal_code' ];
Validator::make( $input, $rules );
更多
以下是Anetwork验证规则使用完整列表
Validator::make( $request->all(), [ 'name' => 'persian_alpha|unique|max:25', // Validate Persian alphabet, unique and max to 25 characters 'age' => 'persian_num|required', // Validate Persian numbers and check it's required 'city' => 'persian_alpha_num|min:10', // Validate persian alphabet & numbers at least 10 digit accepted 'mobile' => 'iran_mobile', // Validate mobile number 'sheba_number' => 'sheba', // Validate sheba number of bank account 'melli_code' => 'melli_code', // Validate melli code number 'latin_name' => 'is_not_persian', // Validate alphabet and doesn't contain Persian alphabet or number 'your_array' => 'limited_array:2', // Validate your array variable and must be contian 2 member or lesser 'url' => 'a_url', // Validate url 'domain' => 'a_domain', // Validate domain 'more' => 'more:10', // Validate value be more than parameter 'less' => 'less:10', // Validate value be less than parameter 'phone' => 'iran_phone', // Validate phone number 'card_number' => 'card_number', // Validate payment card number 'address' => 'address' // validate Persian, English and ... alphabet, Persian and English numbers and some special characters 'postal_code' => 'iran_postal_code' // validate iran postal code format 'package_name' => 'package_name' // validate APK package name ]);