PHP
  Home arrow PHP arrow Building a More Capable Validation Helper Class
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Building a More Capable Validation Helper Class
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2009-08-24


    Table of Contents:
  • Building a More Capable Validation Helper Class
  • Review: the ValidatorHelper class
  • Adding methods for validating IPs, email addresses and URLs
  • The full source code for the improved validation helper class

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building a More Capable Validation Helper Class
    ( Page 1 of 4 )

    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.

    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
     

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek