NoraLib Validation API Documentation

EachRule extends AbstractRule
in package

配列の各要素に対して同じバリデーションルールを適用します

Tags
example
$validator = new Validator();
// 各要素が整数であることをチェック
$rule = $validator->each(
    $validator->custom(fn($v) => is_int($v), 'Must be integer')
);
$rule->assert([1, 2, 3]); // OK
$rule->assert([1, 'two', 3]); // Exception

Table of Contents

Properties

$message  : string
$elementRule  : ValidatorInterface

Methods

__construct()  : mixed
assert()  : void
validate()  : bool
raiseError()  : RuleExceptionInterface

Properties

$message

protected string $message = '配列の要素が不正です。'

Methods

__construct()

public __construct(ValidatorInterface $elementRule[, string $message = '配列の要素が不正です。' ]) : mixed
Parameters
$elementRule : ValidatorInterface
$message : string = '配列の要素が不正です。'

assert()

public assert(mixed $value) : void
Parameters
$value : mixed

validate()

public validate(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

        
On this page

Search results