Validate US States and Canada Provinces
123,894
16
5
Package Data
Maintainer Username: ssx
Maintainer Contact: tylercd100@gmail.com (Tyler Arbon)
Package Create Date: 2017-09-10
Package Last Update: 2024-04-16
Home Page: https://laravel-validation-rules.github.io/
Language: PHP
License: Apache-2.0
Last Refreshed: 2024-12-15 15:07:22
Package Statistics
Total Downloads: 123,894
Monthly Downloads: 5,443
Daily Downloads: 10
Total Stars: 16
Total Watchers: 5
Total Forks: 6
Total Open Issues: 1

State

Validate US States, Canada Provinces, and Mexico States

Installation

composer require laravel-validation-rules/us-state

Usage

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!