G2VALID › An Easy PHP Form Validation Class

Are you among the web developers who struggles with form validation like i did ? tired of nesting if statements ? well here is a solution if you are using PHP.
Let me introduce you to G2VALID. An Easy PHP Form Validation Class to make your life much easier and saves you plenty of time. This class uses OOP PHP so its much easier to use and manage on your projects.
G2VALID › An Easy PHP Form Validation Class FREE

// ————————————————————————————————————|
This validation class requries php 5.0 onwards and few filtering options require C_TYPE |
enabled php configuration. If you are not sure about what this C_TYPE is, contact your |
hosting provider to check if it’s enabled, view your php info for ctype functions. This is usually |
turned on so nothing much to worry. ( tested on hostgator ) //
—————————————————————————————————————-
Okay so lets see what type validation options are available in the alpha stage for us to use. i’m going to be include the method names along with these for easy reference.
Checks for empty input
 | isEmpty($param)   | (@param | String : custom error message)
Checks for valid email
 | validEmail($param)  | (@param | String : custom error message)
Checks for valid URL according to http://www.faqs.org/rfcs/rfc2396
 | validURL($param)   | (@param | String : custom error message)
Checks if the $field is the same as the instace field ( used for password field matching )
 | isSame($field,$error) 
 | (@$field  | String : field to be compared with) |  (@error   | String : custom error message)
 |  Ex Use : ->field('passwd')->isSame('passConfirm','Didnt Match');
Checks for valid Ip Address
 | validIP($param)   | (@param : custom error message)
Check for Minimum Length of a string
 | minLength($min,$error)
 | ($min     | int : the minimum string size)
 |  (@error   | String : custom error message)
Check for Maximum Length of a string
 | maxLength($max,$error)
 | ($max     | int : the minimum string size)
 | (@error   | String : custom error message)
Checks for A-Za-z and space
 | alpha($param)    | (@param | String : custom error message)
Checks for A-Za-z 0-9
 | alphanumeric($param)  | (@param | String : custom error message)
Checks for an valid int
 | isInt($param)  | (@param | String : custom error message)
Checks for an valid float
 | isFloat($param)  | (@param | String : custom error message) 
Now that you know what options available for use, lets simulate a simple form validation.
See, its simple as that and you are good to go. . please also note thatsendEmail(); function used their is for dummy purposes. you can replace it with what ever code you want. The demo above only displayed few possibilities of the the class, lets dig in deeper to see whats available for us to use
Now that you know how easy it is to validate a form, lets dig in deeper to find out what types of reporting is avalible for validations.

1- Get all Errors of a field as array (@return array)


Post a Comment

0 Comments