Orpheus

validators.php

The validators

PHP File containing all basic validators for a website.

Table of Contents

Constants

DATE_FORMAT_GNU  = 1
DATE_FORMAT_LOCALE  = 0

Functions

is_email()  : bool
Check if the input is an email address.
is_string_convertible()  : bool
Check the $variable could be converted into a string
is_id()  : bool
Check if the input is an ID Number.
is_date()  : bool
Check if the input is a date.
is_time()  : bool
Check $time is a real time representation.
is_url()  : bool
Check if the input is an url.
is_ip()  : bool
Check if the input is an ip address.

Constants

DATE_FORMAT_GNU

public mixed DATE_FORMAT_GNU = 1

DATE_FORMAT_LOCALE

public mixed DATE_FORMAT_LOCALE = 0

Functions

is_email()

Check if the input is an email address.

is_email(string $email) : bool
Parameters
$email : string

The email address to check.

Return values
bool

True if $email si a valid email address.

is_string_convertible()

Check the $variable could be converted into a string

is_string_convertible(mixed $variable) : bool
Parameters
$variable : mixed
Return values
bool

is_id()

Check if the input is an ID Number.

is_id(mixed $id) : bool
Parameters
$id : mixed

The number to check

Return values
bool

True if $number si a valid integer

The ID number is an integer.

is_date()

Check if the input is a date.

is_date(string $date[, bool $withTime = false ][, DateTime|null &$dateTime = null ][, int $format = DATE_FORMAT_LOCALE ]) : bool
Parameters
$date : string

The date to check.

$withTime : bool = false

True to use datetime format, optional. Default value is false.

$dateTime : DateTime|null = null

The output timestamp of the data, optional.

$format : int = DATE_FORMAT_LOCALE

The date format to check, see constants DATE_FORMAT_*

Return values
bool

True if $date si a valid date.

The date have to be well formatted and valid. The FR date format is DD/MM/YYYY and time format is HH:MM:SS Allow 01/01/1970, 01/01/1970 12:10:30, 01/01/1970 12:10 Fill missing information with 0.

is_time()

Check $time is a real time representation.

is_time(string $time[, array<string|int, mixed>|null &$matches = null ]) : bool

Could use global translation "timeFormat" to check this is a time e.g. Basically validate 12:50

Parameters
$time : string
$matches : array<string|int, mixed>|null = null
Return values
bool

is_url()

Check if the input is an url.

is_url(string $url) : bool
Parameters
$url : string

The url to check.

Return values
bool

True if $url si a valid url.

is_ip()

Check if the input is an ip address.

is_ip(string $ip[, int $flags = FILTER_DEFAULT ]) : bool
Parameters
$ip : string

The url to check.

$flags : int = FILTER_DEFAULT

The flags for the check.

Tags
sa

filter_var()

Return values
bool

True if $ip si a valid ip address.


							
On this page

Search results