Location: PHPKode > projects > PHP Contact List Grabber > grabbers/validations/validation.class.php
<?php

        /************************************************************************************************
        *       Copyright 2007 Ma'moon Al-Akash hide@address.com                                        *
        *                                                                                               *
        *       This program is free software; you can redistribute it and/or modify                    *
        *       it under the terms of the GNU General Public License as published by                    *
        *       the Free Software Foundation; either version 2 of the License, or                       *
        *       (at your option) any later version.                                                     *
        *                                                                                               *
        *       This program is distributed in the hope that it will be useful,                         *
        *       but WITHOUT ANY WARRANTY; without even the implied warranty of                          *
        *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                           *
        *       GNU General Public License for more details.                                            *
        *                                                                                               *
        *       You should have received a copy of the GNU General Public License                       *
        *       along with this program; if not, write to the Free Software                             *
        *       Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
        *************************************************************************************************/

                        //////////////////////////////////////////////////////////////////////////
                        //      initial credet for this class goes to Ma'moon Al-Akash.         //
                        //      if you have any ideas or suggestions then please contact        //
                        //      me at hide@address.com                                          //
                        //////////////////////////////////////////////////////////////////////////


	/**
	 * This class is used to validate the access parameters needed to make the authentication process valid
	 * it could have been done from the place where each item is being called but it would be much more better
	 * to have it this way in order to maintain future references.
	 */
	class validation{

		// no data members needed here so far!

		/**
		 * Remove the white spaces from the start and end of the items needed to be trimed
		 * @param $item, a reference for the item that needs to be trimed.
		 * @return VOID, nothing to be returned since we are calling this method by reference
		 * NOTE: $item could be an array or any other variable so we need to check if it was an array or not before digging deeper!
		 */
		function validate_trim( &$item ){
			if ( is_array( $item ) ){
				foreach( $item as $key => $value ){
					$item[$key] = trim( $value );
				}
			}else{
				//so far nothing has been implemented here!
			}
		}

                /**
                 * Check if all the items are empty or not, kill the execution if necessary!
                 * @param $item, a reference for the item that needs to be checked for emptiness.
                 * @return VOID, nothing to be returned since we are calling this method by reference
                 * NOTE: $item could be an array or any other variable so we need to check if it was an array or not before digging deeper!
                 */
		function validate_empty( &$item ){
			if ( is_array( $item ) ){
				foreach( $item as $key => $value ){
					if ( empty( $value ) )
						die( 'Please provide the '.strtoupper($key) );
				}
			}else{
				//so far nothing has been implemented here!
			}
		}
	}
?>
Return current item: PHP Contact List Grabber