-
Notifications
You must be signed in to change notification settings - Fork 2
Combinator
Used to combine multiple rules. Validation only succeeds when all rules succeed.
Validation rules are supplied in the constructor of the All rule. All supplied validators must implement \HarmonyIO\Validation\Rule\Rule.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Combinator\All;
use HarmonyIO\Validation\Rule\Text\Ascii;
use HarmonyIO\Validation\Rule\Text\MinimumLength;
use HarmonyIO\Validation\Rule\Text\NoControlCharacters;
(new All(
new Ascii(),
new MinimumLength(10),
new NoControlCharacters(),
))->validate('Lorem ipsum dolor sit amet');List of failures of the validation rules used.
Used to combine multiple rules. Validation succeeds when a single rule succeeds.
Validation rules are supplied in the constructor of the Any rule. All supplied validators must implement \HarmonyIO\Validation\Rule\Rule.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Combinator\Any;
use HarmonyIO\Validation\Rule\Text\Ascii;
use HarmonyIO\Validation\Rule\Text\MinimumLength;
use HarmonyIO\Validation\Rule\Text\NoControlCharacters;
(new Any(
new Ascii(),
new MinimumLength(10),
new NoControlCharacters(),
))->validate('Lorem ipsum dolor sit amet');List of failures of the validation rules used when none of the validators succeed.
Used to combine multiple rules. Validation succeeds when at least the minimum number of successful rules (int) are hit.
Validation rules are supplied in the constructor of the AtLeast rule. All supplied validators must implement \HarmonyIO\Validation\Rule\Rule.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Combinator\AtLeast;
use HarmonyIO\Validation\Rule\Text\Ascii;
use HarmonyIO\Validation\Rule\Text\MinimumLength;
use HarmonyIO\Validation\Rule\Text\NoControlCharacters;
(new AtLeast(
2,
new Ascii(),
new MinimumLength(10),
new NoControlCharacters(),
))->validate('Lorem ipsum dolor sit amet');List of failures of the validation rules used when none of the validators succeed.
Used to negate the result of a validator. Validation succeeds when the validator fails.
The validation rule to negate is supplied in the constructor of the Negate rule. The supplied validator must implement \HarmonyIO\Validation\Rule\Rule.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Combinator\Negate;
use HarmonyIO\Validation\Rule\Text\Ascii;
(new Negate(new Ascii()))->validate('Lorem ipsum dolor sit amet');-
Combinator.Negatewhen the passed in validator succeeds.