GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - graze/data-validator: :oncoming_police_car: Validate data, decoupled from your front end presentation.

BranchesTags
Open more actions menu

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
docs
docs
 
 
src
src
 
 
tests/unit
tests/unit
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.markdownlint.json
.markdownlint.json
 
 
.travis.yml
.travis.yml
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE.md
LICENSE.md
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
composer.lock
composer.lock
 
 
phpcs.xml
phpcs.xml
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 

Repository files navigation

graze/data-validator Build Status Latest Version MIT Licensed

Validate data, decoupled from your front end presentation.

Installation

We recommend installing this library with Composer.

$ 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:

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

License

The content of this library is released under the MIT License by Nature Delivered Ltd.

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

About

🚔 Validate data, decoupled from your front end presentation.

Resources

Readme
MIT license

Contributing

Contributing
Activity
Custom properties

Stars

1 star

Watchers

11 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.