Introduction

Introduction – Introduction to Validate

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')
        )
    )
);
?>
Validate (main package) (Previous) Validation for email addresses. (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

Note by: rjudd@ams-net.org
The PEAR "Date" package is required to process the date as given in the example.