Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/laravel-validation-rules/us-state
Validate US States and Canada Provinces
https://github.com/laravel-validation-rules/us-state
laravel provinces rules states validation
Last synced: 3 months ago
JSON representation
Validate US States and Canada Provinces
- Host: GitHub
- URL: https://github.com/laravel-validation-rules/us-state
- Owner: laravel-validation-rules
- License: apache-2.0
- Created: 2017-09-10T06:47:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-16T12:38:04.000Z (7 months ago)
- Last Synced: 2024-07-19T02:14:24.058Z (4 months ago)
- Topics: laravel, provinces, rules, states, validation
- Language: PHP
- Homepage: https://laravel-validation-rules.github.io/
- Size: 36.1 KB
- Stars: 16
- Watchers: 5
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# State
Validate US States, Canada Provinces, and Mexico States
## Installation
```bash
composer require laravel-validation-rules/us-state
```## Usage
```php
use LVR\State\Abbr;
use LVR\State\Full;# Abbreviation vs Full
$request->validate(['test' => 'UT'], ['test' => new Abbr]); // Pass!
$request->validate(['test' => 'BC'], ['test' => new Abbr); // Pass!
$request->validate(['test' => 'SON'], ['test' => new Abbr); // Pass!
$request->validate(['test' => 'Utah'], ['test' => new Full]); // Pass!
$request->validate(['test' => 'Alberta'], ['test' => new Full]); // Pass!
$request->validate(['test' => 'Sonora'], ['test' => new Full]); // Pass!# Abbreviation - USA vs Canada vs Mexico
$request->validate(['test' => 'UT'], ['test' => new Abbr]); // Pass!
$request->validate(['test' => 'UT'], ['test' => new Abbr('US')]); // Pass!
$request->validate(['test' => 'BC'], ['test' => new Abbr('CA')); // Pass!
$request->validate(['test' => 'SON'], ['test' => new Abbr('MX')); // Pass!# Full - USA vs Canada vs Mexico
$request->validate(['test' => 'Utah'], ['test' => new Full('US')]); // Pass!
$request->validate(['test' => 'Alberta'], ['test' => new Full('CA')]); // Pass!
$request->validate(['test' => 'Sonora'], ['text' => new Full('MX')]); // Pass!
```