API reference / Quittio \ Core \ Validation \ Rules
CallbackRule
final readonly class in quittio/core · implements Rule
Quittio\Core\Validation\Rules\CallbackRule · Source
A rule defined by a closure. The closure receives the invoice and a reporter.
$fallback is the English message used when the message catalog has no entry.
Methods#
| Method | Description |
|---|---|
->__construct() | |
->check() | |
->code() | |
->fallbackMessage() | English message used when the message catalog has no entry for the code. |
::l3() | |
::l7() | |
->level() | Validation level of the rule, as given to the constructor, l3() or l7(). |
->namespace() | Translation namespace of the message catalog the message is looked up in, e.g. "quittio" for "quittio::rules.<code>.message". |
__construct()#
public function __construct(
string $code,
ValidationLevel $level,
string $fallback,
Closure $check,
string $namespace = 'quittio',
)| Parameter | Type | Description |
|---|---|---|
$code | string | |
$level | ValidationLevel | |
$fallback | string | |
$check | Closure | |
$namespace | string = 'quittio' |
check()#
public function check(InvoiceData $invoice, ValidationContext $context): iterable| Parameter | Type | Description |
|---|---|---|
$invoice | InvoiceData | |
$context | ValidationContext |
- Returns
iterable
code()#
public function code(): string- Returns
string
fallbackMessage()#
public function fallbackMessage(): stringEnglish message used when the message catalog has no entry for the code.
- Returns
string
l3()#
public static function l3(
string $code,
string $fallback,
Closure $check,
string $namespace = 'quittio',
): self| Parameter | Type | Description |
|---|---|---|
$code | string | |
$fallback | string | |
$check | Closure | |
$namespace | string = 'quittio' |
- Returns
self
l7()#
public static function l7(
string $code,
string $fallback,
Closure $check,
string $namespace = 'quittio',
): self| Parameter | Type | Description |
|---|---|---|
$code | string | |
$fallback | string | |
$check | Closure | |
$namespace | string = 'quittio' |
- Returns
self
level()#
public function level(): ValidationLevelValidation level of the rule, as given to the constructor, l3() or l7().
- Returns
ValidationLevel
namespace()#
public function namespace(): stringTranslation namespace of the message catalog the message is looked up in, e.g. "quittio" for "quittio::rules.<code>.message".
- Returns
string