risan/lara-rules

Laravel custom validation rules.

v1.0.2 2022-03-02 16:25 UTC

This package is auto-updated.

Last update: 2024-04-29 05:05:21 UTC


README

Laravel custom validation rules.

Latest Stable Version License

Installation

This package requires you to use Laravel version 8. Install this package through Composer.

$ composer require risan/lara-rules

Usage

use Risan\LaraRules\USPhoneWithDash;

$request->validate([
    'phone' => ['required', 'string', new USPhoneWithDash], // Valid: 123-456-7890
    'state' => ['required', 'string', new USStateCode], // Valid: CA, TX
    'zip_code' => ['required', 'string', new USZipCode], // Valid: 90120 or 20521-9000
]);
  • USPhoneWithDash: 10 digits of US phone number with dash.
  • USStateCode: 2 characters of US state code.
  • USZipCode: 5 or 9 digits of US zip code.

License

MIT © Risan Bagja Pradana