class ArrayRule implements Stringable (View source)

Properties

protected array $keys

The accepted keys.

protected array $constraints

The additional constraints for the array rule.

Methods

__construct(Arrayable|array|null $keys = null)

Create a new array rule instance.

between(int $min, int $max)

The field under validation must have between the given min and max number of items (inclusive).

exactly(int $value)

The field under validation must have exactly the given number of items.

max(int $value)

The field under validation must not have more than the given number of items.

min(int $value)

The field under validation must have at least the given number of items.

string
__toString()

Convert the rule to a validation string.

string
arrayRule()

Get the array rule with its accepted keys.

addRule(array|string $rules)

Add custom rules to the validation rules array.

Details

__construct(Arrayable|array|null $keys = null)

Create a new array rule instance.

Parameters

Arrayable|array|null $keys

ArrayRule between(int $min, int $max)

The field under validation must have between the given min and max number of items (inclusive).

Parameters

int $min
int $max

Return Value

ArrayRule

ArrayRule exactly(int $value)

The field under validation must have exactly the given number of items.

Parameters

int $value

Return Value

ArrayRule

ArrayRule max(int $value)

The field under validation must not have more than the given number of items.

Parameters

int $value

Return Value

ArrayRule

ArrayRule min(int $value)

The field under validation must have at least the given number of items.

Parameters

int $value

Return Value

ArrayRule

string __toString()

Convert the rule to a validation string.

Return Value

string

protected string arrayRule()

Get the array rule with its accepted keys.

Return Value

string

protected ArrayRule addRule(array|string $rules)

Add custom rules to the validation rules array.

Parameters

array|string $rules

Return Value

ArrayRule