bigelephant / laravel-rules
There is no license information available for the latest version (dev-master) of this package.
Alternative way to define rules in laravel.
dev-master
2013-02-05 08:49 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.0.x
This package is auto-updated.
Last update: 2024-11-22 04:32:46 UTC
README
Alternative way to define rules in laravel.
This is just for a more PHP like syntax on rules with laravel. I personally find it easier to read at a glance. Also designed to be used in your own validators.
Normal rules in Laravel
$rules = [ 'username' => 'required|alphaDash|between:3,100', 'email' => 'required|email', 'password' => 'required|confirmed|min:5', 'terms' => 'accepted', ];
Under this new syntax
$rules = [ 'username' => Rule::required()->alphaDash()->between(3, 100), 'email' => Rule::required()->email(), 'password' => Rule::required()->confirmed()->min(5), 'terms' => Rule::accepted(), ];
Installation
Add the following to the "require" section of your composer.json
file:
"bigelephant/laravel-rules": "dev-master"
Edit the app/config/app.php
file and...
- Add the following to your
providers
array:
'BigElephant\LaravelRules\RuleServiceProvider',
- Add the following to your
aliases
array:
'Rule' => 'BigElephant\LaravelRules\RuleFacade',