SPHPlayground API
SPHPlayground
sphplayground sphplayground

The DatetimeFormat validator

The DatetimeFormat validates only that the given input has a non empty value. This differs from empty and thus native boolean conversion in PHP.

Predefined errormessage Template formatting parameters:

  1. :value - the string representation of the validated $value
  2. :type - the datatype of the validated $value
    1. :type = "boolean" - for boolean type
    2. :type = "integer" - for integer type
    3. :type = "float" - for float type
    4. :type = "string" - for string type
    5. :type = "array" - for array type
    6. :type = "object" - for object type
    7. :type = "resource" - for resource type
    8. :type = "resource (closed)" - for closed resource type
    9. :type = "NULL" - for nulls
    10. :type = "unknown type" - for unknown types
  3. :strict-type - the strict datatype of the validated $value differs from :type
    1. any object corresponds to the name of the class get_class() results
Synopsis
public const string INVALID_DATETIME
ID for default error message
public const string INVALID
Constructs a new validator
public __construct(string $format = 'Y-m-d H:i:s', string $errorMessage = 'Please insert correct date and time')
Validates given value
public isValid(mixed $value):bool
Invoke validator as a command
public __invoke(mixed $value):bool
Sets an error message template
public setErrorTemplate(string|int $id, TemplateInterface|string $template):void
Returns error message templates
public getErrorTemplates():TemplateContainer
Returns error messages
public getErrors():MessageContainer

The EarlierThan validator

The EarlierThan validator validates whether a date string input or a Date object is earlier than the limit.

Validator specific predefined errormessage Template formatting parameters:

  1. :limit - the minumum allowed value of the validated $value
Synopsis
ID for error message describing values not matching an exclusive limit
public const string INVALID_TYPE
ID for default error message
public const string INVALID
Constructs a new validator
public __construct(Date|DateTimeInterface|string $limit, bool $inclusive = true)
Validates given value
public isValid(mixed $value):bool
Returns the limit
public getLimit():ImmutableDateTime
Checks whether the the limit is set as inclusive or not
public isInclusive():bool
Invoke validator as a command
public __invoke(mixed $value):bool
Sets an error message template
public setErrorTemplate(string|int $id, TemplateInterface|string $template):void
Returns error message templates
public getErrorTemplates():TemplateContainer
Returns error messages
public getErrors():MessageContainer

The LaterThan validator

The LaterThan validator validates whether a date string input or a Date object is later than the limit.

Validator specific predefined errormessage Template formatting parameters:

  1. :limit - the minumum allowed value of the validated $value
Synopsis
ID for error message describing values not matching an exclusive limit
public const string INVALID_TYPE
ID for default error message
public const string INVALID
Constructs a new validator
public __construct(Date|DateTimeInterface|string $limit, bool $inclusive = true)
Validates given value
public isValid(mixed $value):bool
Returns the limit
public getLimit():ImmutableDateTime
Checks whether the the limit is set as inclusive or not
public isInclusive():bool
Invoke validator as a command
public __invoke(mixed $value):bool
Sets an error message template
public setErrorTemplate(string|int $id, TemplateInterface|string $template):void
Returns error message templates
public getErrorTemplates():TemplateContainer
Returns error messages
public getErrors():MessageContainer