https://github.com/tylercd100/laravel-validator-state
Validate states and provinces for USA and Canada with Laravel 5
https://github.com/tylercd100/laravel-validator-state
laravel laravel-5 provinces states validation
Last synced: 7 months ago
JSON representation
Validate states and provinces for USA and Canada with Laravel 5
- Host: GitHub
- URL: https://github.com/tylercd100/laravel-validator-state
- Owner: tylercd100
- License: mit
- Created: 2017-04-13T16:16:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-18T16:07:21.000Z (almost 8 years ago)
- Last Synced: 2025-01-27T08:30:59.560Z (8 months ago)
- Topics: laravel, laravel-5, provinces, states, validation
- Language: PHP
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Validate states and provinces for USA and Canada with Laravel 5
[](https://github.com/tylercd100/laravel-validator-state/releases)
[](LICENSE.md)
[](https://travis-ci.org/tylercd100/laravel-validator-state)
[](https://scrutinizer-ci.com/g/tylercd100/laravel-validator-state/?branch=master)
[](https://scrutinizer-ci.com/g/tylercd100/laravel-validator-state/?branch=master)
[](https://packagist.org/packages/tylercd100/laravel-validator-state)**This Package has moved to [here](https://github.com/laravel-validation-rules/us-state) for laravel 5.5+. Please use that instead. Also check out these other [community validation rules](https://laravel-validation-rules.github.io/)**
## Installation
Install via [composer](https://getcomposer.org/) - In the terminal:
```bash
composer require tylercd100/laravel-validator-state
```Now add the following to the `providers` array in your `config/app.php`
```php
Tylercd100\Validator\State\ServiceProvider::class
```## Usage
```php
# USA vs Canada
Validator::make(['test' => 'UT'], ['test' => 'state']); //true
Validator::make(['test' => 'UT'], ['test' => 'state:usa']); //true
Validator::make(['test' => 'BC'], ['test' => 'state:canada']); //true# Abbreviation vs Full
Validator::make(['test' => 'Utah'], ['test' => 'state:full']); //true
Validator::make(['test' => 'UT'], ['test' => 'state:abbr']); //true# Mix and match
Validator::make(['test' => 'UT'], ['test' => 'state:usa,abbr']); //true
Validator::make(['test' => 'Alberta'], ['test' => 'state:canada,full']); //true
```