2017 © Pedro Peláez
 

library data-validator

Validate data, decoupled from your front end presentation.

image

graze/data-validator

Validate data, decoupled from your front end presentation.

  • Tuesday, February 16, 2016
  • by graze
  • Repository
  • 12 Watchers
  • 1 Stars
  • 7,416 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

graze/data-validator Build Status Latest Version MIT Licensed

Validate data, decoupled from your front end presentation., (*1)

Installation

We recommend installing this library with Composer., (*2)

$ composer require graze/data-validator

Usage

use Graze\DataValidator\DataValidator;

$validator = new DataValidator();

// Add a processor to roughly capitalize first names.
$validator->addProcessor(function (array $data) {
    $data['first_name'] = ucfirst($data['first_name']);
    return $data;
});

// Add a validator to check against a 'reserved' list.
$validator->addValidator(function (array $data) {
    if (in_array($data['first_name'], ['Sam', 'John', 'Ray'])) {
        return 'reserved_name';
    }
});

/** @var array */
$processed = $validator->process(['first_name' => 'sam']);

/** @var array */
$failures = $validator->validate($processed);

var_dump($failures);

The above would output:, (*3)

array(1) {
  ["reserved_name"]=>
  bool(true)
}

License

The content of this library is released under the MIT License by Nature Delivered Ltd., (*4)

You can find a copy of this license at http://www.opensource.org/licenses/mit or in LICENSE., (*5)

The Versions

16/02 2016

dev-master

9999999-dev

Validate data, decoupled from your front end presentation.

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

16/02 2016
16/02 2016