<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ukeloop / laravel-validation-rule-builder example snippets
use Illuminate\Support\Facades\Validator;
use Ukeloop\ValidationRuleBuilder\ValidationRuleBuilder;
Validator::make($input, [
'title' => (new ValidationRuleBuilder())->
use Ukeloop\ValidationRuleBuilder\ValidationRuleBuilder;
$validationRule = new ValidationRuleBuilder();
$validationRule->ionRule->numeric();
$validationRule->date();
$validationRule->bool();
$validationRule->min(8);
$validationRule->max(255);
$validationRule->email('strict', 'dns');
// etc ...
$validationRule->add(Password::min(8));
new ValidationRuleBuilder(
function ($attribute, $value, $fail) {
if ($value === 'foo') {
$fail('The ' . $attribute . ' is invalid.');
}
}
);
use Ukeloop\ValidationRuleBuilder\RuleSet;
class EmailRuleSet extends RuleSet
{
public static function rules(): ValidationRuleBuilder
{
return new ValidationRuleBuilder('email:strict,dns,spoof');
}
}
use Illuminate\Support\Facades\Validator;
Validator::make($input, [
'email' => EmailRuleSet::rules()->somtime()->
use Ukeloop\ValidationRuleBuilder\RuleSet;
class PasswordRuleSet extends RuleSet
{
public static function rules(): ValidationRuleBuilder
{
return new ValidationRuleBuilder(
Password::min(8)
->letters()
->mixedCase()
->numbers()
->symbols()
);
}
}
use Illuminate\Support\Facades\Validator;
Validator::make($input, [
'password' => PasswordRuleSet::rules()->
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.