vakata/validation

A validation class

1.9.5 2024-05-17 14:30 UTC

This package is auto-updated.

Last update: 2024-11-17 15:28:48 UTC


README

Latest Version on Packagist Software License Build Status Code Climate Tests Coverage

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

Install

Via Composer

$ composer require vakata/validation

Usage

$v = new \vakata\validation\Validator();
$v
    ->required('name', 'requiredN')->alpha(null, "alphaN")->notEmpty("empty")
    ->required('family', 'requiredF')->alpha(null, "alphaF")
    ->required('age', 'requiredA')->numeric("numericA")
    ->optional("newsletter")->numeric("numericN")
    ->optional("children.*.name")->alpha(null, "alphaC")
    ->optional("children.*.age")->numeric(null, "numericC");
$errors = $v->run($_POST);
// inspect the array - if empty - the data is valid

Read more in the API docs

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email github@vakata.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.