Useful Laravel Validation Rule Packages

Useful Laravel Validation Rule Packages

Laravel Validation Rules is a GitHub organization containing a collection of useful validation rules that you can pull into any project quickly and not have to write them yourself. At the time of writing here’s the list of validation rule packages:

  • Colour (currently supports hex)
  • Country Codes
  • Credit Card
  • IP
  • Phone
  • Subdomain
  • Timezone
  • US States and CA Provinces

Here’s an example from the documentation using the US states validation package:

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' => 'Utah'], ['test' => new Full]); // Pass!
$request->validate(['test' => 'Alberta'], ['test' => new Full]); // Pass!

# Abbreviation - USA vs Canada
$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!

# Full - USA vs Canada
$request->validate(['test' => 'Utah'], ['test' => new Full('US')]); // Pass!
$request->validate(['test' => 'Alberta'], ['test' => new Full('CA')]); // Pass!

To learn more about this project, check out the Laravel Validation Rules documentation. You can view the source code of the various validators by browsing repositories in the GitHub organization.

Filed in: News / packages
Laravel News Partners

Laravel Jobs

Backend Software Engineer (PHP Developer)
Austin TX, Bonita Springs FL
Certified eSupport Corp
Laravel Developer
Glendale, CA (COVID Remote)
Jogg, Inc
Senior PHP Engineer
Remote, USA Only
Full-Stack Engineer (Mid to Senior)
Remote (EST, CST)
Senior Laravel Developer (AI Applications)
Remote from anywhere in the UK or from our London office
GreenShoot Labs


Join 31,000+ others and never miss out on new tips, tutorials, and more.