2017 © Pedro Peláez
 

library validator

simple php form validator

image

tyurderi/validator

simple php form validator

  • Tuesday, May 31, 2016
  • by tyurderi
  • Repository
  • 0 Watchers
  • 1 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 9 % Grown

The README.md

Simple PHP Validator

This is my version of a simple php validator class., (*1)

Install

composer require tyurderi/validator

Usage

``` php $v = new Validator\Validator();, (*2)

$v->addRule('unique_username', function($fields, $value, $params) { // logic goes here return true; });, (*3)

$v->add('username', 'tyurderi', 'required|min:3|max:30|unique_username', array( 'required' => 'The username is required.', 'min' => 'The username should be at least 3 characters long.', 'max' => 'The username should be at most 30 characters long.', 'unique_username' => 'The username is already in use.' ));, (*4)

$v->validate();, (*5)

if ($v->passes()) { echo 'Validation was successfully!'; } else { echo 'Validation failed.', PHP_EOL; foreach ($v->errors() as $message) { echo $message, PHP_EOL; } }, (*6)

```, (*7)

Available rules

required

The value must be not empty., (*8)

in:1,2,3

The value should equals 1, 2 or 3., (*9)

email

The value should be a valid email address., (*10)

notin:1, 2, 3

The value should not equals 1, 2 or 3., (*11)

min:3

The value should be at least 3 characters long., (*12)

max:30

The value should be at most 30 characters long., (*13)

len:30

The value should be exact 30 characters long., (*14)

min_value:3

The value should equal or greater than 3., (*15)

max_value:30

The value should equal or smaller than 30., (*16)

matches:anotherField

The value should equal with the value of another registered field., (*17)

is:someValue

The value should equals the value at parameter 1. (someValue), (*18)

min_words:3

The value should contain at least 3 words., (*19)

License

MIT, (*20)

The Versions

31/05 2016

dev-master

9999999-dev

simple php form validator

  Sources   Download

MIT

by Avatar tyurderi

31/05 2016

1.0.1

1.0.1.0

simple php form validator

  Sources   Download

MIT

by Avatar tyurderi

31/05 2016

1.0.0

1.0.0.0

simple php form validator

  Sources   Download

by Avatar tyurderi