PHP Classes

Rules Validation Class: Validate request values according to common rules

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 81 All time: 10,094 This week: 660Up
Version License PHP version Categories
validationclass 1.0.0The PHP License5PHP 5, Validation
Description 

Author

This class can validate request values according to common rules.

It can take an array of GET or POST request values and validate them with given rules.

Currently it supports validation rules for values as: required, email, name, date and time, amount, URL, etc..

Picture of Chike Jibunoh
Name: Chike Jibunoh <contact>
Classes: 2 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 368829 in Nigeria Nigeria
Week rank: 200 Up6 in Nigeria Nigeria Up

Example

<?php
//This is just an example of the usage, not really a working application
$rules = array(
'email' => 'email|required',
'username' => 'name_user|required',
'password' => 'required',
'firstname' => 'name|required',
'lastname' => 'name|required'
);

$validation = new Validation();

if(
$validation->validate($_POST, $rules) == TRUE) {
$email = trim($_POST['email']);
$username = trim($_POST['username']);
$firstname = trim($_POST['firstname']);
$lastname = trim($_POST['lastname']);
$password = hash('sha1', trim($_POST['password']));
$cf_password = hash('sha1',trim($_POST['cf_password']));

}
foreach (
$validation->errors as $error) {
        echo
"<div class = 'alert alert-danger'>" . $error . "</div>";

    }


Details

myprojects


  Files folder image Files (3)  
File Role Description
Accessible without login Plain text file classvalidationexample.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation
Plain text file validationclass.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:81
This week:0
All time:10,094
This week:660Up