class Numeric implements Stringable (View source)

Traits

Properties

protected $constraints

The constraints for the number rule.

Methods

$this|TWhenReturnType
when($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

$this|TUnlessReturnType
unless($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

between(int|float $min, int|float $max)

The field under validation must have a size between the given min and max (inclusive).

decimal(int $min, int|null $max = null)

The field under validation must contain the specified number of decimal places.

different(string $field)

The field under validation must have a different value than field.

digits(int $length)

The integer under validation must have an exact number of digits.

digitsBetween(int $min, int $max)

The integer under validation must between the given min and max number of digits.

greaterThan(string $field)

The field under validation must be greater than the given field or value.

greaterThanOrEqualTo(string $field)

The field under validation must be greater than or equal to the given field or value.

integer()

The field under validation must be an integer.

lessThan(string $field)

The field under validation must be less than the given field.

lessThanOrEqualTo(string $field)

The field under validation must be less than or equal to the given field.

max(int|float $value)

The field under validation must be less than or equal to a maximum value.

maxDigits(int $value)

The integer under validation must have a maximum number of digits.

min(int|float $value)

The field under validation must have a minimum value.

minDigits(int $value)

The integer under validation must have a minimum number of digits.

multipleOf(int|float $value)

The field under validation must be a multiple of the given value.

same(string $field)

The given field must match the field under validation.

exactly(int $value)

The field under validation must match the given value.

string
__toString()

Convert the rule to a validation string.

addRule(array|string $rules)

Add custom rules to the validation rules array.

Details

$this|TWhenReturnType when($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

$value
callable|null $callback
callable|null $default

Return Value

$this|TWhenReturnType

$this|TUnlessReturnType unless($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

$value
callable|null $callback
callable|null $default

Return Value

$this|TUnlessReturnType

Numeric between(int|float $min, int|float $max)

The field under validation must have a size between the given min and max (inclusive).

Parameters

int|float $min
int|float $max

Return Value

Numeric

Numeric decimal(int $min, int|null $max = null)

The field under validation must contain the specified number of decimal places.

Parameters

int $min
int|null $max

Return Value

Numeric

Numeric different(string $field)

The field under validation must have a different value than field.

Parameters

string $field

Return Value

Numeric

Numeric digits(int $length)

The integer under validation must have an exact number of digits.

Parameters

int $length

Return Value

Numeric

Numeric digitsBetween(int $min, int $max)

The integer under validation must between the given min and max number of digits.

Parameters

int $min
int $max

Return Value

Numeric

Numeric greaterThan(string $field)

The field under validation must be greater than the given field or value.

Parameters

string $field

Return Value

Numeric

Numeric greaterThanOrEqualTo(string $field)

The field under validation must be greater than or equal to the given field or value.

Parameters

string $field

Return Value

Numeric

Numeric integer()

The field under validation must be an integer.

Return Value

Numeric

Numeric lessThan(string $field)

The field under validation must be less than the given field.

Parameters

string $field

Return Value

Numeric

Numeric lessThanOrEqualTo(string $field)

The field under validation must be less than or equal to the given field.

Parameters

string $field

Return Value

Numeric

Numeric max(int|float $value)

The field under validation must be less than or equal to a maximum value.

Parameters

int|float $value

Return Value

Numeric

Numeric maxDigits(int $value)

The integer under validation must have a maximum number of digits.

Parameters

int $value

Return Value

Numeric

Numeric min(int|float $value)

The field under validation must have a minimum value.

Parameters

int|float $value

Return Value

Numeric

Numeric minDigits(int $value)

The integer under validation must have a minimum number of digits.

Parameters

int $value

Return Value

Numeric

Numeric multipleOf(int|float $value)

The field under validation must be a multiple of the given value.

Parameters

int|float $value

Return Value

Numeric

Numeric same(string $field)

The given field must match the field under validation.

Parameters

string $field

Return Value

Numeric

Numeric exactly(int $value)

The field under validation must match the given value.

Parameters

int $value

Return Value

Numeric

string __toString()

Convert the rule to a validation string.

Return Value

string

protected Numeric addRule(array|string $rules)

Add custom rules to the validation rules array.

Parameters

array|string $rules

Return Value

Numeric