2017 © Pedro Peláez
 

library extended-validation

Extending the Laravel validation rules with some useful additions.

image

developerswarehouse/extended-validation

Extending the Laravel validation rules with some useful additions.

  • Tuesday, March 6, 2018
  • by simonhughes
  • Repository
  • 0 Watchers
  • 0 Stars
  • 2 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Extended Validation Rules

A simple package for adding additional regex matches to the Validator., (*1)

Installation

composer require developerswarehouse/extended-validation

Usage

The package will load the validation rules from the config file, then extend Laravel's Validator with the key given, as the new validation rule. You will be able to use the new rules in the same way as the built in validations that come with Laravel., (*2)

Request Validation (docs)

public function store(Request $request)
{
    $validatedData = $request->validate([
        'code' => 'required|alpha_dot_alpha',
        'key' => 'required|alpha_dot_alpha_num',
        'token' => 'required|alpha_num_underscore_alpha_num',
    ]);
}

Form Requests (docs)

public function authorize()
{
    return true;
}

public function rules()
{
    return [
        'code' => 'required|alpha_dot_alpha',
        'key' => 'required|alpha_dot_alpha_num',
        'token' => 'required|alpha_num_underscore_alpha_num',
    ];
}

Publish

You are not required to publish the package, but if you wish to extend/alter the rules config, then you will need to., (*3)

 php artisan vendor:publish

Add Your Validation

In config/extended-validation.php you will see a list of rules like:, (*4)

return [
    'rules' => [
        "alpha_dot" => "/^[\pL\pM\pN.]+$/i",
        "alpha_dot_alpha" => "/^[a-z]+\.[a-z]+$/i",
        "alpha_dot_num" => "/^[a-z]+\.[0-9]+$/i",
        "num_dot_alpha" => "/^\d+\.[a-z]+$/i",

        // ...

    ]
];

Feel free to add, remove or modify the rules to better suit your needs. If you are not familiar with regular expressions, I would suggest you test your rules using an Online Regex Tester., (*5)

The Versions

06/03 2018

dev-master

9999999-dev https://bitbucket.org/developerswarehouse/extended-validation

Extending the Laravel validation rules with some useful additions.

  Sources   Download

MIT

The Requires

 

by Simon Hughes

06/03 2018

0.2

0.2.0.0 https://bitbucket.org/developerswarehouse/extended-validation

Extending the Laravel validation rules with some useful additions.

  Sources   Download

MIT

The Requires

 

by Simon Hughes

14/01 2018

dev-develop

dev-develop https://bitbucket.org/developerswarehouse/extended-validation

Extending the Laravel validation rules with some useful additions.

  Sources   Download

MIT

The Requires

 

by Simon Hughes

14/01 2018

0.1

0.1.0.0 https://bitbucket.org/developerswarehouse/extended-validation

Extending the Laravel validation rules with some useful additions.

  Sources   Download

MIT

The Requires

 

by Simon Hughes