ISO8601DateTimeRule extends Rule
Validates whether a value is a valid ISO 8601 date-time expression.
Accepted shape:
- Date :
YYYY-MM-DD(extended) - Sep. :
T(mandatory in strict mode, space allowed when$strict = false) - Time :
HH:MM:SS, optionally with fractional seconds (.fff...) - Offset: optional
Z,±HH:MMor±HHMM
Calendar validity is checked (February 30 is rejected, leap years honored).
✅ Supported examples (strict mode, the default):
2026-05-14T08:15:30Z
2026-05-14T08:15:30+02:00
2026-05-14T08:15:30.123Z
❌ Invalid examples (strict mode):
2026-05-14 // date only — use ISO8601DateRule
2026-05-14 08:15:30 // space separator (allowed when strict = false)
2026-02-30T00:00:00Z // invalid calendar date
Empty / null values pass — the rule is "shape" only, declare Rules::REQUIRED
separately when the field is mandatory.
Tags
Table of Contents
Constants
- NAME : string = \oihana\validations\enums\Rules::ISO8601_DATE_TIME
- The rule name, as registered in the validation factory.
Properties
- $message : string
- The message pattern used when the rule fails.
- $strict : bool
- Whether the rule runs in strict mode (T separator mandatory).
Methods
- __construct() : mixed
- Creates a new ISO8601DateTimeRule instance.
- check() : bool
- Checks whether the given value satisfies the rule.
Constants
NAME
The rule name, as registered in the validation factory.
public
string
NAME
= \oihana\validations\enums\Rules::ISO8601_DATE_TIME
Tags
Properties
$message
The message pattern used when the rule fails.
protected
string
$message
= "The :attribute is not a valid ISO 8601 date-time expression."
$strict
Whether the rule runs in strict mode (T separator mandatory).
protected
bool
$strict
Methods
__construct()
Creates a new ISO8601DateTimeRule instance.
public
__construct([bool $strict = true ][, string|null $message = null ]) : mixed
Parameters
- $strict : bool = true
-
When true (default), the
Tseparator is mandatory. - $message : string|null = null
-
Optional custom error message.
check()
Checks whether the given value satisfies the rule.
public
check(mixed $value) : bool
Parameters
- $value : mixed
-
The value to validate.
Return values
bool —True if the value is a valid ISO 8601 date-time; false otherwise.