2017 © Pedro Peláez
 

library validator

Validator Component for validate variables such as strings, numbers and arrays

image

jessehu/validator

Validator Component for validate variables such as strings, numbers and arrays

  • Thursday, August 3, 2017
  • by zhibuzu
  • Repository
  • 1 Watchers
  • 1 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

validator

Validator Component for validate variables such as strings, numbers and arrays, (*1)

Usage

require '../vendor/autoload.php';

use Jessehu\Component\Validator\Validation;

use Jessehu\Component\Validator\Contraints\NotBlank;

$validator = Validation::createValidator();

// use Contraints Object
$violations = $validator->validate('Jessehu', array(
    new NotBlank('this variable can\'t be blank')
));

// or use custom closure
$violations = $validator->validate('Jessehu', array(
    function ($value) {
        if ('Jesse hu' !== $value) {
            return 'variable value must be Jesse hu';
        }

        return true;
    }
));

if (0 !== count($violations)) {
    // 类型错误信息
    foreach ($violations as $violation) {
        echo $violation->getMessage().'<br>';
        echo $vialation->getCodes().'<br>';
    }
}

Variable type validator

validate variable type, (*2)

Usage

require '../vendor/autoload.php';

use Jessehu\Component\Validator\VariableTypeValidator;

$title = '25日视频直播国王vs勇士 库里一纪录冲历史前3';
$isNbaNews = true;
$score = 45;

$validator = VariableTypeValidator::createValidator();
$violations = $validator->validate(array(
   'title' => array('is_string', $title),
   'isNbaNews' => array('is_bool', $isNbaNews),
   'score' => array('is_int', $score)
));

if (0 !== count($violations)) {
    // 类型错误信息
    foreach ($violations as $violation) {
        echo $violation->getMessage().'<br>';
        echo $vialation->getCode().'<br>';
    }
}

The Versions

03/08 2017

dev-master

9999999-dev

Validator Component for validate variables such as strings, numbers and arrays

  Sources   Download

MIT

The Requires

  • php >5.3.0

 

The Development Requires

by jesse

php validator

09/06 2017

v1.0.3

1.0.3.0

Validator Component for validate variables such as strings, numbers and arrays

  Sources   Download

MIT

The Requires

  • php >5.3.0

 

The Development Requires

by jesse

php validator

08/06 2017

v1.0.2

1.0.2.0

Validator Component for validate variables such as strings, numbers and arrays

  Sources   Download

MIT

The Requires

  • php >5.3.0

 

The Development Requires

by jesse

php validator

07/06 2017

v1.0.1

1.0.1.0

Validator Component for validate variables such as strings, numbers and arrays

  Sources   Download

MIT

The Requires

  • php >5.3.0

 

The Development Requires

by jesse

php validator

03/04 2017

dev-zhibuzu-patch-2

dev-zhibuzu-patch-2

Validator Component for validate variables such as strings, numbers and arrays

  Sources   Download

MIT

The Requires

  • php >5.3.0

 

The Development Requires

by jesse

php validator

27/03 2017

v1.0.0

1.0.0.0

Validator Component for validate variables such as strings, numbers and arrays

  Sources   Download

MIT

The Requires

  • php >5.3.0

 

The Development Requires

by jesse

php validator

27/03 2017

dev-zhibuzu-patch-1

dev-zhibuzu-patch-1

Validator Component for validate variables such as strings, numbers and arrays

  Sources   Download

MIT

The Requires

  • php >5.3.0

 

The Development Requires

by jesse

php validator

06/03 2017

dev-dev

dev-dev

validate form data

  Sources   Download

Apache2.0

The Development Requires

by jesse