final class DatetimeLt extends Rule (View source)

Adds datetime.lt rule. Asserts that the input is a datetime string/object less than (before) the given datetime string.

This is an auto-generated class that was generated programmatically by: MAKS\Mighty\Maker

Constants

NAME

Properties

protected array<string,string|null> $messages

Constraint rules messages overrides.

from  Constraint
protected Strategy $strategy

Constraint strategy.

from  Constraint
protected string $validation

Constraint validation expression.

from  Constraint
protected Validator Since: 1.2.0
$validator

Constraint validator instance.

from  Constraint

Methods

__construct(string $datetime, string|null $message = null, Strategy $strategy = Strategy::FailLazy)

Rule constructor.

void
check(mixed $value = null)

Checks if the given value is valid and throws an exception if not.

static Validator
getMasterValidator()

Returns the master Validator instance that should be used in validation.

array
getMessages()

Gets constraint rules messages overrides.

Strategy
getStrategy()

Gets constraint strategy.

string
getValidation()

Gets constraint validation expression.

getValidator()

Gets constraint validator instance.

bool
isValid(mixed $value = null)

Checks if the given value is valid.

setMessages(array $messages)

Sets constraint rules messages overrides.

setStrategy(Strategy $strategy)

Sets constraint strategy.

setValidation(string $validation)

Sets constraint validation expression.

setValidator(Validator $validator)

Sets constraint validator instance.

Result
validate(mixed $value = null)

Validates the given value and returns the validation result.

from  Rule

Details

__construct(string $datetime, string|null $message = null, Strategy $strategy = Strategy::FailLazy)

Rule constructor.

Parameters

string $datetime
string|null $message
Strategy $strategy

void check(mixed $value = null)

Checks if the given value is valid and throws an exception if not.

Parameters

mixed $value

The value to validate.

Return Value

void

Exceptions

ValidationFailedException

final static protected Validator getMasterValidator()

Since: 1.2.0 This method used to be called `getValidator()` before `v1.2.0`.

Returns the master Validator instance that should be used in validation.

NOTE: All constraint share the same Validator. Always clone it to avoid any side effects.

FACT: The idea of master Validator is used to allow for better memory management and faster load times as the default Validator loads 200+ rules by default. Cloning will make a shallow copy resulting in reusing the same rules loaded by the master Validator.

Return Value

Validator

array getMessages()

Gets constraint rules messages overrides.

Return Value

array

Strategy getStrategy()

Gets constraint strategy.

Return Value

Strategy

string getValidation()

Gets constraint validation expression.

Return Value

string

Validator getValidator()

Since: 1.2.0

Gets constraint validator instance.

This method returns a clone of the master Validator if a Validator is not set explicitly via self::setValidator().

Return Value

Validator

bool isValid(mixed $value = null)

Checks if the given value is valid.

Parameters

mixed $value

The value to validate.

Return Value

bool

Whether the value is valid or not.

Constraint setMessages(array $messages)

Sets constraint rules messages overrides.

Parameters

array $messages

Return Value

Constraint

Constraint setStrategy(Strategy $strategy)

Sets constraint strategy.

Parameters

Strategy $strategy

Return Value

Constraint

Constraint setValidation(string $validation)

Sets constraint validation expression.

Parameters

string $validation

Return Value

Constraint

Constraint setValidator(Validator $validator)

Since: 1.2.0

Sets constraint validator instance.

Parameters

Validator $validator

Constraint validator instance.

Return Value

Constraint

Result validate(mixed $value = null)

Validates the given value and returns the validation result.

Parameters

mixed $value

The value to validate.

Return Value

Result

The validation result (single or multiple).