Validator
Generic validation class used throughout the Alpha Framework.
Tags
Table of Contents
- ALLOW_ALL = '/.*/i'
- Allows any kind of input, including blanks.
- OPTIONAL_HTTP_URL = '/(http|https).*|^$/i'
- Optional HTTP URL value.
- REQUIRED_ALPHA = '/^[a-zA-Z]+$/'
- Required alphabet string.
- REQUIRED_ALPHA_NUMERIC = '/^[a-zA-Z0-9]+$/'
- Required alpha-numeric string.
- REQUIRED_ALPHA_UPPER = '/^[A-Z]+$/'
- Required uppercase alphabet string.
- REQUIRED_DOUBLE = '/^-{0,1}[0-9\.]+$/'
- Required double value.
- REQUIRED_EMAIL = '/^[-_.a-zA-Z0-9]+@((([a-zA-Z0-9]|[-_.a-zA-Z0-9]*[a-zA-Z0-9])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|email|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i'
- Required email address value.
- REQUIRED_HTTP_URL = '/^((http|https):\/\/.*)$/i'
- Required HTTP URL value.
- REQUIRED_INTEGER = '/^-{0,1}[0-9]*$/'
- Required integer value.
- REQUIRED_IP = '/^(((([1-9])|([1-9][\d])|(1[\d]{2})|(2[0-4][\d])|(25[0-4]))(\.(([\d])|([1-9][\d])|(1[\d]{2})|(2[0-4][\d])|(25[0-4]))){3})|(0(\.0){3}))$/'
- Required IP address value.
- REQUIRED_SEQUENCE = '/^[A-Z]*-[0-9]*$/'
- Required sequence value.
- REQUIRED_STRING = '/^[\S]{1}.{0,254}$/'
- Required string value, accepts a maximum of 255 characters.
- REQUIRED_TEXT = '/^[\S]{1}.{0,65535}$/'
- Required text value, accepts a maximum of 65536 characters.
- REQUIRED_USERNAME = '/^[-_\.a-zA-Z0-9]+$/'
- Required username (allows a-z A-Z 0-9 and -_. characters).
- isAlpha() : bool
- Validate that the provided value is a valid alphabetic string (strictly a-zA-Z).
- isAlphaNum() : bool
- Validate that the provided value is a valid alpha-numeric string (strictly a-zA-Z0-9).
- isBase64() : bool
- Validate that the provided value is base64 encoded (best guess by regex).
- isBoolean() : bool
- Validate that the provided value is a valid boolean (will accept 1 or 0 as valid booleans).
- isBooleanTrue() : bool
- Validate that the provided value is a valid boolean true or not (true, 'true', 1, '1', 'on').
- isDouble() : bool
- Validate that the provided value is a valid double.
- isEmail() : bool
- Validate that the provided value is a valid email address.
- isHTML() : bool
- Will return true if the value provided contains any HTML code that is stripable by the native strip_tags() function.
- isInteger() : bool
- Validate that the provided value is a valid integer.
- isIP() : bool
- Validate that the provided value is a valid IP address.
- isSequence() : bool
- Validate that the provided value is a valid Sequence string ([A-Z]-[0-9]).
- isURL() : bool
- Validate that the provided value is a valid URL.
Constants
ALLOW_ALL
Allows any kind of input, including blanks.
public
string
ALLOW_ALL
= '/.*/i'
Tags
OPTIONAL_HTTP_URL
Optional HTTP URL value.
public
string
OPTIONAL_HTTP_URL
= '/(http|https).*|^$/i'
Tags
REQUIRED_ALPHA
Required alphabet string.
public
string
REQUIRED_ALPHA
= '/^[a-zA-Z]+$/'
Tags
REQUIRED_ALPHA_NUMERIC
Required alpha-numeric string.
public
string
REQUIRED_ALPHA_NUMERIC
= '/^[a-zA-Z0-9]+$/'
Tags
REQUIRED_ALPHA_UPPER
Required uppercase alphabet string.
public
string
REQUIRED_ALPHA_UPPER
= '/^[A-Z]+$/'
Tags
REQUIRED_DOUBLE
Required double value.
public
string
REQUIRED_DOUBLE
= '/^-{0,1}[0-9\.]+$/'
Tags
REQUIRED_EMAIL
Required email address value.
public
string
REQUIRED_EMAIL
= '/^[-_.a-zA-Z0-9]+@((([a-zA-Z0-9]|[-_.a-zA-Z0-9]*[a-zA-Z0-9])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|email|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i'
Tags
REQUIRED_HTTP_URL
Required HTTP URL value.
public
string
REQUIRED_HTTP_URL
= '/^((http|https):\/\/.*)$/i'
Tags
REQUIRED_INTEGER
Required integer value.
public
string
REQUIRED_INTEGER
= '/^-{0,1}[0-9]*$/'
Tags
REQUIRED_IP
Required IP address value.
public
string
REQUIRED_IP
= '/^(((([1-9])|([1-9][\d])|(1[\d]{2})|(2[0-4][\d])|(25[0-4]))(\.(([\d])|([1-9][\d])|(1[\d]{2})|(2[0-4][\d])|(25[0-4]))){3})|(0(\.0){3}))$/'
Tags
REQUIRED_SEQUENCE
Required sequence value.
public
string
REQUIRED_SEQUENCE
= '/^[A-Z]*-[0-9]*$/'
Tags
REQUIRED_STRING
Required string value, accepts a maximum of 255 characters.
public
string
REQUIRED_STRING
= '/^[\S]{1}.{0,254}$/'
Tags
REQUIRED_TEXT
Required text value, accepts a maximum of 65536 characters.
public
string
REQUIRED_TEXT
= '/^[\S]{1}.{0,65535}$/'
Tags
REQUIRED_USERNAME
Required username (allows a-z A-Z 0-9 and -_. characters).
public
string
REQUIRED_USERNAME
= '/^[-_\.a-zA-Z0-9]+$/'
Tags
Methods
isAlpha()
Validate that the provided value is a valid alphabetic string (strictly a-zA-Z).
public
static isAlpha( $value) : bool
Parameters
Tags
Return values
bool —isAlphaNum()
Validate that the provided value is a valid alpha-numeric string (strictly a-zA-Z0-9).
public
static isAlphaNum( $value) : bool
Parameters
Tags
Return values
bool —isBase64()
Validate that the provided value is base64 encoded (best guess by regex).
public
static isBase64( $value) : bool
Parameters
Tags
Return values
bool —isBoolean()
Validate that the provided value is a valid boolean (will accept 1 or 0 as valid booleans).
public
static isBoolean( $value) : bool
Parameters
Tags
Return values
bool —isBooleanTrue()
Validate that the provided value is a valid boolean true or not (true, 'true', 1, '1', 'on').
public
static isBooleanTrue( $value) : bool
Parameters
Tags
Return values
bool —isDouble()
Validate that the provided value is a valid double.
public
static isDouble( $value) : bool
Parameters
Tags
Return values
bool —isEmail()
Validate that the provided value is a valid email address.
public
static isEmail(mixed $email) : bool
Parameters
- $email : mixed
Tags
Return values
bool —isHTML()
Will return true if the value provided contains any HTML code that is stripable by the native strip_tags() function.
public
static isHTML( $value) : bool
Parameters
Tags
Return values
bool —isInteger()
Validate that the provided value is a valid integer.
public
static isInteger( $value) : bool
Parameters
Tags
Return values
bool —isIP()
Validate that the provided value is a valid IP address.
public
static isIP(mixed $ip) : bool
Parameters
- $ip : mixed
Tags
Return values
bool —isSequence()
Validate that the provided value is a valid Sequence string ([A-Z]-[0-9]).
public
static isSequence( $value) : bool
Parameters
Tags
Return values
bool —isURL()
Validate that the provided value is a valid URL.
public
static isURL(mixed $url) : bool
Parameters
- $url : mixed