2017 © Pedro Peláez
 

library easy-validation

Easy Validation is an easy and simple PHP validation library

image

amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  • Thursday, December 14, 2017
  • by amitkhare
  • Repository
  • 1 Watchers
  • 1 Stars
  • 33 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 3 % Grown

The README.md

amitkhare/easy-validation

Easy Validation is an easy to use PHP validation library, (*1)

Install

Run this command from the directory in which you want to install., (*2)

Via Composer:

php composer.phar require amitkhare/easy-validation

Via Git:

git clone https://github.com/amitkhare/easy-validation.git

Manual Install:

Download: https://github.com/amitkhare/easy-validation/archive/master.zip
Extract it, require "PATH-TO/"."EasyValidation.php" where you want to use it.

Minimal Usage:

<?php

require("PATH-TO/"."EasyValidation.php"); // only need to include if installed manually.

$v = new AmitKhare\EasyValidation\EasyValidation(); // instantiate EasyValidation;

$v->setSource($_POST); // set data source array;

$v->setLocale("en-IN","PATH/TO/LOCALES/DIRECTORY/"); 

$v->check("email","required|email|unique:users.email|min:4|max:100");
$v->match("password","password_confirm","required|min:6|max:25");

if(!$v->isValid()){
    print_r($v->getStatus());
}

Usage:

<?php
use AmitKhare\EasyValidation; // use namespace.

require("PATH-TO/"."EasyValidation.php"); // only need to include if installed manually.

$v = new EasyValidation(); // instantiate EasyValidation;

//  OR with database for unique field check
$v = new EasyValidation($host,$username,$password,$dbname); // instantiate EasyValidation With Database features;

$v->setSource($_POST); // set data source array;


// check bottom of this file for sample en-IN.lang file
$v->setLocale("en-IN","PATH/TO/LOCALES/DIRECTORY/"); 

$v->check("mobile","required|numeric|min:10|max:15");
$v->check("username","required|alphanum|unique:users.username|min:4|max:20");
$v->check("email","required|email|unique:users.email|min:4|max:100");

$v->match("password","password_confirm","required|min:6|max:25");

if(!$v->isValid()){
    print_r($v->getStatus());
}

Available Methods:

> $v->setSource(array["FIELD"=>"VALUE"]);
> $v->setLocale("en-IN",PATH); // Path is optional
> $v->check("FIELD","RULES");
> $v->match("FIELD1","FIELD2","RULES");
> $v->isValid();  // returns true/false
> $v->getStatus(); // get error messages

Available Rules:

> required
> email
> url
> numeric
> string
> float
> ipv4
> ipv6
> bool
> min
> max
> alphanum
> alphanumUnicode
> unique (avaiable only if instantiate EasyValidation With Database Details);

Sample en-IN.lang file [[ JSON FORMAT ]]

    {

    "FIELDS_DONT_MATCH" : "The `%s` dont match with `%s`.",
    "FIELD_REQUIRED" : "The `%s` is required.",
    "FIELD_NOT_SET" : "The `%s` field is not set.",

    "USERNAME":"Username",
    "FIRSTNAME":"First Name",
    "LASTNAME":"Last Name",
    "MIDDLENAME":"Middle Name",
    "EMAIL":"Email",
    "PASSWORD":"Password",
    "MOBILE":"Mobile",
    "PASSWORD_CONFIRM":"Password Confirm"

    }

TODO:

> Support for single field check like setField() in addition with setSource()

The Versions

14/12 2017

dev-master

9999999-dev http://github.com/amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  Sources   Download

MIT

The Requires

 

by Amit Kumar Khare

14/12 2017

0.5.9

0.5.9.0 http://github.com/amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  Sources   Download

MIT

The Requires

 

by Amit Kumar Khare

28/09 2017

0.5.8

0.5.8.0 http://github.com/amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  Sources   Download

MIT

The Requires

 

by Amit Kumar Khare

28/09 2017

0.5.7

0.5.7.0 http://github.com/amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  Sources   Download

MIT

The Requires

 

by Amit Kumar Khare

28/09 2017

0.5.6

0.5.6.0 http://github.com/amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  Sources   Download

MIT

The Requires

 

by Amit Kumar Khare

28/09 2017

0.5.5

0.5.5.0 http://github.com/amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Amit Kumar Khare

27/09 2017

0.5.4

0.5.4.0 http://github.com/amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Amit Kumar Khare

27/09 2017

0.5.3

0.5.3.0 http://github.com/amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Amit Kumar Khare

27/09 2017

0.5.2

0.5.2.0 http://github.com/amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Amit Kumar Khare

27/09 2017

0.5.1

0.5.1.0 http://github.com/amitkhare/easy-validation

Easy Validation is an easy and simple PHP validation library

  Sources   Download

MIT

by Amit Kumar Khare