2017 © Pedro Peláez
 

library validator

Server side user input validation library

image

pingle/validator

Server side user input validation library

  • Wednesday, February 17, 2016
  • by FaizRasool
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Pingle Validator

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

You can install Validator either via package download from github or via composer install. I encourage you to do the latter:, (*2)

{ 
  "require": {
    "pingle/validator": "dev-master"
  }
} 

This is a small PHP class that makes it easy to validate forms in your project specially larger forms. Pingle Validator class provide the validation for the user input on the server side., (*3)

Basic usage

namespace Pingle/Validator;

//initialize the class
$val = new Validator();

/*** use POST as the source ***/
$val->addSource($_POST);

/*** add a form field rule ***/
/*** addRule('name', 'type', required, min, max, trim, regex)***/
$val->addRule('name', 'string', true, 5, 255, true)
    ->addRule('email', 'email', true, 1, 255, true)
    ->addRule('website', 'url', false, 1, 255, true)
    ->addRule('age', 'numeric', true, 1, 100, true)
    ->addRule('salary', 'float', false, 1, 99999999, true)
    ->addRule('date', 'regex', true, 10, 10, true,"#^(((?:0?[1-9]|1[012])|(?:0?[1-9]|[12][0-9]|3[01])|([a-zA-Z]+))([.,]?[-.\\\/\s]))?(((?:0?[1-9]|1[012])|(?:0?[1-9]|[12][0-9]|3[01])|([a-zA-Z]+))([.,]?[-.\\\/\s]))?((?:20|19)[0-9]{2})$#");
/*** run the validation rules ***/
$val->run();
/*** if there are errors show them ***/
if(sizeof($val->errors) > 0)
{
    print_r($val->errors);
}
else
{
    $_POST=$val->sanitized;
}

### Validation Methods

  1. string
  2. email
  3. url
  4. numeric
  5. float
  6. regex
  7. ipv4
  8. ipv6
  9. bool

The Versions

17/02 2016

dev-master

9999999-dev

Server side user input validation library

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Faiz Rasool