Introduction
Overview
With this package, one can easily validate various data. It includes numbers, email, string, date, URI and posibility valid multiple data with a single method call.
Some of above mentioned features have corresponding RFCs, in case, Validate conforms to those RFCs. For example email validation mostly covers RFC 822 or URI conforms to RFC 2396.
A few examples
Validating an email address
<?php
require_once 'Validate.php';
if (!Validate::email('johndoe@example.net')) {
echo 'Invalid Email address';
} else {
echo 'Its Valid!';
}
?>
Validating dates
In this example, date would first checked against desired format, and then get checked to see if it's not before "15 February 1986" or after "23 August 2008".
<?php
require_once 'Validate.php';
var_dump(
Validate::date(
'121202',
array(
'format' => '%d%m%y',
'min' => array('15', '02', '1986'),
'max' => array('23', '08', '2008')
)
)
);
?>