sadegh19b/laravel-persian-validation

为Laravel提供的波斯字母、数字等验证包

1.5.1 2024-03-15 23:41 UTC

This package is auto-updated.

Last update: 2024-09-16 00:39:42 UTC


README

Laravel Persian Validation提供了波斯字母、数字等的验证

需求

  • Laravel 6, 7, 8, 9, 10, 11
  • PHP 7.4, 8, 8.1, 8.2

安装

通过Composer

composer require sadegh19b/laravel-persian-validation

发布语言文件

要发布自定义验证消息的语言文件,请执行以下命令。这将文件放置在 resources/lang/{locale}/persian-validation.php。

php artisan vendor:publish --provider="Sadegh19b\LaravelPersianValidation\PersianValidationServiceProvider"

用法

您可以通过传递以下表格中的规则键来访问验证规则

波斯字母

接受符合标准波斯语的波斯语字母,您可以使用此验证规则的方式如下

$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 );

波斯字母英数字

验证波斯字母数字和英文字母数字

$input = [ '۰فارسی۱۲۳۴۵6789' ];

$rules = [ 'persian_alpha_eng_num' ];

Validator::make( $input, $rules );

伊斯兰历日期

验证伊斯兰历(波斯历)日期

$input = [ '1373/3/19' ];

$rules = [ 'shamsi_date' ];

Validator::make( $input, $rules );

伊斯兰历日期之间

验证伊斯兰历(波斯历)日期在年份之间

$input = [ '1373/3/19' ];

$rules = [ 'shamsi_date_between:1300,1400' ];

Validator::make( $input, $rules );

伊朗手机号

验证伊朗手机号码(Irancell, Rightel, Hamrah-e-aval, ...)

$input = [ '09381234567' ];

$rules = [ 'ir_mobile' ];

Validator::make( $input, $rules );

谢巴号码

验证伊朗银行谢巴号码

$input = [ 'IR062960000000100324200001' ];

$rules = [ 'ir_sheba' ];

Validator::make( $input, $rules );

伊朗国家代码

验证伊朗国家代码(Melli Code)

$input = [ '3240175800' ];

$rules = [ 'ir_national_code' ];

Validator::make( $input, $rules );

支付卡号码

验证伊朗银行支付卡号码

$input = [ '6274129005473742' ];

$rules = [ 'ir_bank_card_number' ];

Validator::make( $input, $rules );

伊朗邮政编码

验证伊朗邮政编码

$input = [ '167197-35744' ];

$rules = [ 'ir_postal_code' ];

Validator::make( $input, $rules );

or

$input = [ '16719735744' ];

$rules = [ 'ir_postal_code' ];

Validator::make( $input, $rules );

伊朗公司ID

验证伊朗国家法律实体标识符(Shenase Melli Ashkhas Hoghoghi)

$input = [ '14007650912' ];

$rules = [ 'ir_company_id' ];

Validator::make( $input, $rules );

更多

波斯验证规则用法完整列表

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

  'address'       => 'persian_alpha_eng_num',  // Validate persian alphabet & numbers with english numbers

  'birthday'      => 'shamsi_date', // Validate shamsi date 

  'start_date'    => 'shamsi_date_between:1300,1400', // Validate shamsi date between years

  'mobile'        => 'ir_mobile', // Validate mobile number

  'sheba_number'  => 'ir_sheba', // Validate sheba number of bank account

  'melli_code'    => 'ir_national_code',  // Validate melli code number

  'latin_name'    => 'persian_not_accept',  // Validate alphabet and doesn't contain Persian alphabet or number

  'url'           => 'a_url', // Validate url

  'domain'        => 'a_domain',  // Validate domain

  'phone'         => 'ir_phone', // Validate phone number
  
  'area_code'     => 'ir_phone_code', // Validate phone area code
  
  'phone_code'    => 'ir_phone_with_code', // Validate phone number with area code

  'card_number'   => 'ir_bank_card_number', // Validate payment card number

  'postal_code'   => 'ir_postal_code' // validate iran postal code format
  
  'company_id'    => 'ir_company_id',  // Iranian National Legal Entity Identifier (Shenase Melli Ashkhas Hoghoghi)

]);

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件