CodeCanyon

Data Validation class

The key to a stable and secure application or website is data validation. Validating things like email addresses, numbers, and other data can be very time consuming and add a lot of extra lines of code to your website if you want to do it the right way. This class can make the data validation part of website development a lot easier.

This class is very easy to use. Because all the methods are static they are faster and callable without instantiating the class. This will say that you only need to include the PHP file in your code and do the validations like below. The method returns a boolean (true when it’s valid, false when invalid). To show you some examples:

Email validation:

if(!Validator::Email("wim(at)test.com")){
    echo "Your email is invalid";
}

Email validation and don’t accept addresses that end with test.com or test.be:

if(!Validator::Email("wim(at)test.com", array("test.com", "test.be"))){
    echo "Your email is invalid";
}

Check if a number is between 20 and 50:

if(!Validator::Number(35, 50, 20)){
    echo "The number is not between 20 and 50";
}

Check if a user is older than 18:

if(!Validator::OlderThan("1966-2-5", 17)){
    echo "You must be older than 18.";
}

Features

  • Email
  • Url
  • IP
  • Phone numbers
  • Number (extra parameter to check if the number is between min and max)
  • Unsigned Number
  • Float
  • Alpha
  • Alpha numeric
  • String length is between min and max characters
  • Hexcolor
  • Date
  • Check if someone born on date x is older than x years
  • Valid XML
  • Filesize between min and max bytes
  • Image dimensions between width is beween min and max and/or height is between min and max pixels

Updates

13/12/2009:

  • Added chars validation
  • Fixed Alpha method typo

18/11/2009:

  • Added phone number validation
  • Fixed wrong images :)

You must sign in or sign up to purchase this item.

$3Regular Licence

$3

Regular Licence a website (commercial, personal, client), or intranet site project - Details

$15Extended Licence

$15

Extended Licence a website template for sale (including on ThemeForest or ActiveDen) - Details

183 Purchases 20 Comments

Buyer Rating
12345 ( 37 ratings )
Sitebase

Sitebase

  • Has been a member for 2-3 years
  • Won a Competition
  • Author had a File in an Envato Bundle
  • Envato Staff
  • Reviewer
  • Author had a Free File of the Month
  • Exclusive Author
  • Beta Tester
  • Sold between 100 000 and 250 000 dollars
  • Elite Author
  • Bought between 10 and 49 items
  • Belgium
  • Referred between 100 and 199 users
View Portfolio
Created 13 November 09
Compatible Browsers FireFox 2, FireFox 3, IE6, IE7, IE8, Safari
Software Version PHP 5.x
Software Framework N/A
Files Included PHP
by
by
by
by
by