Validates that a given value is a DateTime instance or can be converted into one.
Methods
Set default options for this instance
__construct(array $options)
Validator()
- one or multiple scalar values f.e. Validator($first, $second, $third)
- an array f.e. Validator(array($first => 'first', $second => 'second', $third => 'third'))
- an instance of Traversable f.e. Validator($config_instance)
Parameters
$options
array
Magic function returns the value of the requested property, if and only if it is the value or a
message variable.
__get(string $property) : mixed
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::__get() |
inherited_from |
\Zend\Validator\Date::__get() |
Parameters
$property
string
Exceptions
Returns
mixed
Invoke as command
__invoke(mixed $value) : bool
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::__invoke() |
inherited_from |
\Zend\Validator\Date::__invoke() |
Parameters
$value
mixed
Returns
bool
Returns the base value from which the step should be computed
getBaseValue() : string | int | \DateTime
Get default translation object for all validate objects
getDefaultTranslator() : \Zend\Validator\Translator\TranslatorInterface | null
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getDefaultTranslator() |
inherited_from |
\Zend\Validator\Date::getDefaultTranslator() |
Returns
Get default translation text domain for all validate objects
getDefaultTranslatorTextDomain() : string
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getDefaultTranslatorTextDomain() |
inherited_from |
\Zend\Validator\Date::getDefaultTranslatorTextDomain() |
Returns
string
Returns the maximum allowed message length
getMessageLength() : int
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getMessageLength() |
inherited_from |
\Zend\Validator\Date::getMessageLength() |
Returns
int
Returns the message templates from the validator
getMessageTemplates() : array
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getMessageTemplates() |
inherited_from |
\Zend\Validator\Date::getMessageTemplates() |
Returns
array
Returns an array of the names of variables that are used in constructing validation failure messages
getMessageVariables() : array
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getMessageVariables() |
inherited_from |
\Zend\Validator\Date::getMessageVariables() |
Returns
array
Returns array of validation failure messages
getMessages() : array
Inherited
The array keys are validation failure message identifiers,
and the array values are the corresponding human-readable message strings.
If isValid() was never called or if the most recent isValid() call
returned true, then this method returns an empty array.
inherited_from |
\Zend\Validator\AbstractValidator::getMessages() |
inherited_from |
\Zend\Validator\Date::getMessages() |
Returns
array
Returns an option
getOption(string $option) : mixed
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getOption() |
inherited_from |
\Zend\Validator\Date::getOption() |
Parameters
$option
string
Option to be returned
Exceptions
Returns
mixed
Returned option
Returns all available options
getOptions() : array
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getOptions() |
inherited_from |
\Zend\Validator\Date::getOptions() |
Returns
array
Array with all available options
Return translation object
getTranslator() : \Zend\Validator\Translator\TranslatorInterface | null
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getTranslator() |
inherited_from |
\Zend\Validator\Date::getTranslator() |
Returns
Return the translation text domain
getTranslatorTextDomain() : string
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getTranslatorTextDomain() |
inherited_from |
\Zend\Validator\Date::getTranslatorTextDomain() |
Returns
string
Is there a default translation object set?
hasDefaultTranslator() : bool
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::hasDefaultTranslator() |
inherited_from |
\Zend\Validator\Date::hasDefaultTranslator() |
Returns
bool
Does this validator have its own specific translator?
hasTranslator() : bool
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::hasTranslator() |
inherited_from |
\Zend\Validator\Date::hasTranslator() |
Returns
bool
Is translation enabled?
isTranslatorEnabled() : bool
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::isTranslatorEnabled() |
inherited_from |
\Zend\Validator\Date::isTranslatorEnabled() |
Returns
bool
Returns true if a date is within a valid step
isValid(string | int | \DateTime $value) : bool
If $value fails validation, then this method returns false, and
getMessages() will return an array of messages that explain why the
validation failed.
Parameters
Exceptions
Returns
bool
Retrieve flag indicating whether or not value should be obfuscated in
messages
isValueObscured() : bool
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::isValueObscured() |
inherited_from |
\Zend\Validator\Date::isValueObscured() |
Returns
bool
Set default translation object for all validate objects
setDefaultTranslator(\Zend\Validator\Translator\TranslatorInterface $translator, string $textDomain) : void
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setDefaultTranslator() |
inherited_from |
\Zend\Validator\Date::setDefaultTranslator() |
Parameters
$textDomain
string
(optional)
Exceptions
Set default translation text domain for all validate objects
setDefaultTranslatorTextDomain(string $textDomain) : void
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain() |
inherited_from |
\Zend\Validator\Date::setDefaultTranslatorTextDomain() |
Parameters
$textDomain
string
Sets the validation failure message template for a particular key
setMessage(string $messageString, string $messageKey) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setMessage() |
inherited_from |
\Zend\Validator\Date::setMessage() |
Parameters
$messageString
string
$messageKey
string
OPTIONAL
Exceptions
Returns
Sets the maximum allowed message length
setMessageLength(int $length)
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setMessageLength() |
inherited_from |
\Zend\Validator\Date::setMessageLength() |
Parameters
$length
int
Sets validation failure message templates given as an array, where the array keys are the message keys,
and the array values are the message template strings.
setMessages(array $messages) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setMessages() |
inherited_from |
\Zend\Validator\Date::setMessages() |
Parameters
$messages
array
Returns
Sets one or multiple options
setOptions(array | \Traversable $options) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setOptions() |
inherited_from |
\Zend\Validator\Date::setOptions() |
Parameters
$options
array\Traversable
Options to set
Exceptions
Returns
Set translation object
setTranslator(\Zend\Validator\Translator\TranslatorInterface $translator, string $textDomain) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setTranslator() |
inherited_from |
\Zend\Validator\Date::setTranslator() |
Parameters
$textDomain
string
(optional)
Exceptions
Returns
Indicate whether or not translation should be enabled
setTranslatorEnabled(bool $flag) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setTranslatorEnabled() |
inherited_from |
\Zend\Validator\Date::setTranslatorEnabled() |
Parameters
$flag
bool
Returns
Set translation text domain
setTranslatorTextDomain(string $textDomain) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setTranslatorTextDomain() |
inherited_from |
\Zend\Validator\Date::setTranslatorTextDomain() |
Parameters
$textDomain
string
Returns
Set flag indicating whether or not value should be obfuscated in messages
setValueObscured(bool $flag) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setValueObscured() |
inherited_from |
\Zend\Validator\Date::setValueObscured() |
Parameters
$flag
bool
Returns
Implodes the array into a string and proxies to {@link convertString()}.
convertArray(array $value, bool $addErrors) : bool | \DateTime
Inherited
inherited_from |
\Zend\Validator\Date::convertArray() |
Parameters
$value
array
$addErrors
bool
Returns
Attempts to convert an double into a DateTime object
convertDouble(double $value) : bool | \DateTime
Inherited
inherited_from |
\Zend\Validator\Date::convertDouble() |
Parameters
$value
double
Returns
Attempts to convert an integer into a DateTime object
convertInteger(integer $value) : bool | \DateTime
Inherited
inherited_from |
\Zend\Validator\Date::convertInteger() |
Parameters
$value
integer
Returns
Supports formats with ISO week (W) definitions
convertString(string $value, bool $addErrors) : bool | \DateTime
see |
\Zend\Validator\Date::convertString() |
Parameters
$value
string
$addErrors
bool
Returns
Attempts to convert an int, string, or array to a DateTime object
convertToDateTime(string | int | array $param, bool $addErrors) : bool | \DateTime
Inherited
inherited_from |
\Zend\Validator\Date::convertToDateTime() |
Parameters
$param
stringintarray
$addErrors
bool
Returns
Constructs and returns a validation failure message with the given message key and value.
createMessage(string $messageKey, string | array | object $value) : string
Inherited
Returns null if and only if $messageKey does not correspond to an existing template.
If a translator is available and a translation exists for $messageKey,
the translation will be used.
inherited_from |
\Zend\Validator\AbstractValidator::createMessage() |
inherited_from |
\Zend\Validator\Date::createMessage() |
Parameters
$messageKey
string
$value
stringarrayobject
Returns
string
error()
error(string $messageKey, string $value) : void
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::error() |
inherited_from |
\Zend\Validator\Date::error() |
Parameters
$messageKey
string
Returns the validation value
getValue() : mixed
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getValue() |
inherited_from |
\Zend\Validator\Date::getValue() |
Returns
mixed
Value to be validated
Sets the value to be validated and clears the messages and errors arrays
setValue(mixed $value) : void
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setValue() |
inherited_from |
\Zend\Validator\Date::setValue() |
Parameters
$value
mixed
Translate a validation message
translateMessage(string $messageKey, string $message) : string
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::translateMessage() |
inherited_from |
\Zend\Validator\Date::translateMessage() |
Parameters
$messageKey
string
$message
string
Returns
string
Get lower bound of difference in secondss
Converts a given `$diffParts` array into seconds
computeDiffMinSeconds(array $diffParts) : int
Parameters
$diffParts
int[]
Returns
int
Get upper bound of the given interval in seconds
Converts a given `$intervalParts` array into seconds
computeIntervalMaxSeconds(array $intervalParts) : int
Parameters
$intervalParts
int[]
Returns
int
computeMinStepAndRequiredIterations()
computeMinStepAndRequiredIterations(array $intervalParts, array $diffParts) : int[]
Parameters
$intervalParts
int[]
$diffParts
int[]
Returns
int[]
(ordered tuple containing minimum steps and required step iterations
Multiply the step interval by the lower bound of steps to reach the target
computeMinSteps(array $intervalParts, array $diffParts) : int
Parameters
$intervalParts
int[]
$diffParts
int[]
Returns
int
Computes minimum interval to use for iterations while checking steps
computeMinimumInterval(array $intervalParts, int $minSteps) : \DateInterval
Parameters
$intervalParts
int[]
$minSteps
int
Returns
Fall back to slower (but accurate) method for complex intervals.
fallbackIncrementalIterationLogic(\DateTime $baseDate, \DateTime $valueDate, array $intervalParts, array $diffParts, \DateInterval $step) : bool
Keep adding steps to the base date until a match is found
or until the value is exceeded.
This is really slow if the interval is small, especially if the
default base date of 1/1/1970 is used. We can skip a chunk of
iterations by starting at the lower bound of steps needed to reach
the target
Parameters
$intervalParts
int[]
$diffParts
int[]
Returns
bool
Properties
$abstractOptions
$abstractOptions
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::$$abstractOptions |
inherited_from |
\Zend\Validator\Date::$$abstractOptions |
Optional base date value
$baseValue : string | int | \DateTime
Default translation object for all validate objects
$defaultTranslator : \Zend\Validator\Translator\TranslatorInterface
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::$$defaultTranslator |
inherited_from |
\Zend\Validator\Date::$$defaultTranslator |
Default text domain to be used with translator
$defaultTranslatorTextDomain : string
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::$$defaultTranslatorTextDomain |
inherited_from |
\Zend\Validator\Date::$$defaultTranslatorTextDomain |
Limits the maximum returned length of an error message
$messageLength : int
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::$$messageLength |
inherited_from |
\Zend\Validator\Date::$$messageLength |
Validation failure message template definitions
$messageTemplates : array
$messageVariables
$messageVariables : array
Inherited
inherited_from |
\Zend\Validator\Date::$$messageVariables |
Date step interval (defaults to 1 day).
$step : \DateInterval
Uses the DateInterval specification.
Optional timezone to be used when the baseValue
and validation values do not contain timezone info
$timezone : \DateTimeZone
The value to be validated
$value : mixed
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::$$value |
inherited_from |
\Zend\Validator\Date::$$value |
Constants
INVALID
INVALID
Inherited
inherited_from |
\Zend\Validator\Date::INVALID |
INVALID_DATE
INVALID_DATE
Inherited
inherited_from |
\Zend\Validator\Date::INVALID_DATE |