laravel-validation-rules/us-state

Validate US States and Canada Provinces
183,845 16
Install
composer require laravel-validation-rules/us-state
Latest Version:1.9.0
License:Apache-2.0
Last Updated:Apr 1, 2025
Links: GitHub  ·  Packagist
Maintainer: ssx

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!

Related Packages

laravel-validation-rules/us-phone

Validate that a phone number is in the correct format

0 0
tylercd100/laravel-validator-phone

Validate that a phone number is in the correct format

4,377 3
tylercd100/laravel-validator-state

Validate that a states and provinces for US and Canada

44 1
laravel-validation-rules/phone

Validate that a phone number is in the correct format

376,086 69
tylercd100/laravel-validator-color

Validate that a certain value is a valid CSS color string in Laravel 5

81,186 15