项目作者: tylercd100

项目描述 :
Validate states and provinces for USA and Canada with Laravel 5
高级语言: PHP
项目地址: git://github.com/tylercd100/laravel-validator-state.git
创建时间: 2017-04-13T16:16:05Z
项目社区:https://github.com/tylercd100/laravel-validator-state

开源协议:MIT License

下载


Validate states and provinces for USA and Canada with Laravel 5

Latest Version
Software License
Build Status
Scrutinizer Code Quality
Code Coverage
Total Downloads

This Package has moved to here for laravel 5.5+. Please use that instead. Also check out these other community validation rules

Installation

Install via composer - In the terminal:

  1. composer require tylercd100/laravel-validator-state

Now add the following to the providers array in your config/app.php

  1. Tylercd100\Validator\State\ServiceProvider::class

Usage

  1. # USA vs Canada
  2. Validator::make(['test' => 'UT'], ['test' => 'state']); //true
  3. Validator::make(['test' => 'UT'], ['test' => 'state:usa']); //true
  4. Validator::make(['test' => 'BC'], ['test' => 'state:canada']); //true
  5. # Abbreviation vs Full
  6. Validator::make(['test' => 'Utah'], ['test' => 'state:full']); //true
  7. Validator::make(['test' => 'UT'], ['test' => 'state:abbr']); //true
  8. # Mix and match
  9. Validator::make(['test' => 'UT'], ['test' => 'state:usa,abbr']); //true
  10. Validator::make(['test' => 'Alberta'], ['test' => 'state:canada,full']); //true