PHP code example of fadion / rule
1. Go to this page and download the library: Download fadion/rule library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fadion / rule example snippets
$rules = [
'username' => 'l'
];
Rule::add('username')->quired()->email();
$rules = Rule::get();
$inputs = Input::all();
Rule::add('username')->dator = Validator::make($inputs, Rule::get());
if ($validator->fails()) {
Return::back()->withInput()->withErrors($validator);
}
Rule::add('date')->date_format('mm/dd/YYYY');
Rule::add('age')->between(5, 15);
Rule::add('role')->in(['Admin', 'Moderator', 'Editor']);
Rule::add('username')->exists('users');
Rule::add('username')->exists('users', 'name');
Rule::add('username')->exists('users', 'name', 'id', 10);
Rule::add('email')->unique('users');
Rule::add('email')->unique('users', 'email_address', 10);
Rule::add('email')->unique('users', 'email_address', 10, 'account_id', 1);
Validator::extend('foo', function($attribute, $value, $parameters) {
return $value == 'foo';
});
Rule::add('name')->
Rule::add('languages')->is_array();
Rule::add('date')->date_format('Y-m-d');
Rule::add('date')->dateFormat('Y-m-d');
Rule::add('username')->alpha_dash();
Rule::add('username')->alphaDash();
Rule::add('name', 'Your name')->)->t::all(), Rule::get());
// Apply attributes
$validator->setAttributeNames(Rule::getAttributes());
Rule::add('email')
->Email appears to be invalid.");
Rule::add('password')
->();
$messages = Rule::getMessages();