Delivering the best Add-Ons in more than 37 languages.

中文(简体), English, हिन्दी/हिंदी, Español/Castellano, العربية, Русский язык, Français, 中文 (台灣), বাংলা, Bahasa Indonesia, اردو, Português, Deutsch, Bahasa Melayu (بهاس ملايو‎), 日本語 (にほんご), فارسی, Italiano, తెలుగు, Türkçe, ગુજરાતી, Język polski/polszczyzna, Tiếng Việt, ಕನ್ನಡ, Українська мова, ไทย
PHP Scripts / Miscellaneous

Data Validation class

— Add-On to

Subscribe to our feed to stay up to date!

New! Follow us as you want it!

Data Validation class - CodeCanyon Item for Sale


Ad: Bluehost hosting

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)")){ echo "Your email is invalid"; } 

Email validation and don’t accept addresses that end with or

 if(!Validator::Email("wim(at)", array("", ""))){ 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."; } 


  • 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



  • Added chars validation
  • Fixed Alpha method typo


  • Added phone number validation
  • Fixed wrong images :)

Other components in this categoryAll components of this author
CommentsFrequently asked questions and answers


13 November 09

Last Update:
13 November 09

Compatible Browsers:
Firefox, IE6, IE7, IE8, Safari

Files Included:

Software Framework:

Software Version:
PHP 5.x


eCommerce, eCommerce, All Items, data, date, email, numeric, php class, security, test, url, validation, variables