Home arrow PHP arrow Building a More Capable Validation Helper Class

Building a More Capable Validation Helper Class

In this sixth part of an eight-part series on helper classes, I finish developing the validation helper class created in the previous part. We'll add even more useful validation methods to expand its functionality.

TABLE OF CONTENTS:
  1. Building a More Capable Validation Helper Class
  2. Review: the ValidatorHelper class
  3. Adding methods for validating IPs, email addresses and URLs
  4. The full source code for the improved validation helper class
By: Alejandro Gervasio
Rating: starstarstarstarstar / 4
August 24, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Quite often, helper classes are overlooked by developers taking their first steps in PHP-based web development. They are used to encapsulate all of the functionality required to perform certain tasks in full-featured, large-scale libraries, which sometimes contributes to breaking down the intrinsic modularity imposed by the object-oriented paradigm.

However, experienced programmers know that helper classes play an important role when it comes to speeding up the development of web applications, in typical situations where itís necessary to dynamically generate different portions of a URL, validate incoming data or apply different formatting filters to a group of database records.

Given the relevance that helper classes have in the life of conscientous PHP developers, they deserve a closer analysis that must be complemented with a decent variety of examples that show how to build them and how to use them in concrete cases.

So, if youíre interested in learning the basic concepts that surround the creation of helpers, then this series of articles might provide the material for which youíre looking.

Logically, if you had the chance to read all of the tutorials that precede this one, then itís quite probable that you now have a more solid background in building several helper classes with PHP 5. In those articles I offered numerous examples that hopefully demonstrated how to accomplish this process in a relatively easy way.

In the last chapter I started developing a simple helper class whose main task was to validate different types of data, such as integer and float numbers, and alphabetic and alphanumeric values, by using the capabilities provided by the  PHP filters extension.

Admittedly, in its current state, this helper class has limited functionality. It would be really useful to add more methods to it to validate other things, like email and IP addresses, to mention just two examples. Thus, in the next few lines Iím going to extend the abilities of this helper class so it can be used to perform the validation processes mentioned above.

Now, itís time to get rid of the preliminaries and keep digging deeper into the huge terrain of PHP helper classes. Letís get going!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: