Valdi\Validator\AbstractDateTimeComparator

class Valdi\Validator\AbstractDateTimeComparator
Abstract validator to compare date times. For the format, see: http://php.net/manual/en/datetime.createfromformat.php
property $amountOfParameters

Holds the amount of parameters.

property $type

Holds the type of the validator.

property $dateTimeParameters

Holds whether to parse the parameters as \DateTimes so the child class can decide.

isValidComparison()

Compares date times.

Parameters:
  • $date (\DateTime) – the first date to compare
  • $datetimes (\DateTime[]) – the date times to compare to
  • $parameters (array) – the original validator parameters
Returns:

boolean $ true if the dates compare

getDateTimeFormat()

Gets a date time format from the parameters if given or a default one.

Parameters:
  • $parameters (string[]) – the parameters
Returns:

string $ the date time format

getDateTimes()

Interprets the given parameters as date times and returns them.

Parameters:
  • $parameters (array) – the parameters
  • $format (string) – the date time format
Returns:

\DateTime[] $ the date times

Throws:

ValidationException $ thrown if one of the parameters is not a date in the given format

isValid()

{@inheritdoc}

getInvalidDetails()

{@inheritdoc}