Class Validation
Class to provide reusable validation rules.
Used for object types and properties.
Methods summary
public static
|
#
clear( )
Clear reserved names list
Clear reserved names list
|
protected static
string[]
|
#
reservedWords( )
Load list of reserved names in $reserved
Load list of reserved names in $reserved
Returns
string[]
|
public static
boolean
|
#
notReserved( mixed $value )
Check if a value is not reserved
Check if a value is not reserved
Parameters
Returns
boolean
|
public static
boolean
|
#
requireNull( mixed $value )
Require a value to be null
Require a value to be null
Parameters
Returns
boolean
|
public static
boolean
|
#
url( string $value )
Checks that a value is a valid URL or custom url as myapp://
Checks that a value is a valid URL or custom url as myapp://
Parameters
Returns
boolean
|
public static
true|string
|
#
jsonSchema( mixed $value, mixed $schema )
Validate using JSON Schema.
Validate using JSON Schema.
Parameters
- $value
- Value being validated.
- $schema
- Schema to validate against.
Returns
true|string
|
public static
true|string
|
#
languageTag( string $tag )
Validate language tag using I18n configuration.
Validate language tag using I18n configuration.
Parameters
Returns
true|string
|
public static
true|string
|
#
dateTime( mixed $value )
Validate input date and datetime.
Accepetd input formats:
- string date format
- integer timestamps
- DateTime objects
Validate input date and datetime.
Accepetd input formats:
- string date format
- integer timestamps
- DateTime objects
Accepted date time string formats are
- 2017-01-01 YYYY-MM-DD
- 2017-01-01 11:22 YYYY-MM-DD hh:mm
- 2017-01-01T11:22:33 YYYY-MM-DDThh:mm:ss
- 2017-01-01T11:22:33Z YYYY-MM-DDThh:mm:ssZ
- 2017-01-01T19:20+01:00 YYYY-MM-DDThh:mmTZD
- 2017-01-01T11:22:33+0100 YYYY-MM-DDThh:mm:ssTZD
- 2017-01-01T19:20:30.45+01 YYYY-MM-DDThh:mm:ss.sTZD
See ISO 8601 subset as defined here https://www.w3.org/TR/NOTE-datetime:
Valid TZD formats are: ±hh:mm, ±hhmm and ±hh, e.g. +01:00, +0100 and +01
Also timestamp as integer are accepted.
Parameters
- $value
- Date or datetime value
Returns
true|string
|
Properties summary
protected static
string[]|null
|
$reserved
The list of reserved names
The list of reserved names
|
|