chrgriffin/laravel-strict-validator

'Strict' validator for PHP arrays. Currently only supported in Laravel.

v1.0.2 2018-05-15 17:08 UTC

This package is auto-updated.

Last update: 2024-12-23 08:29:19 UTC


README

'Strict' validator for PHP arrays. Currently only supported in Lumen/Laravel as it uses the Laravel validation implementation. Use this package to add 'strict' validation in addition to the normal Laravel validation rules.

'Strict' Rules

  1. Arrays can only contain fields under validation. Any 'extra' indexes will cause the validator to return false.
  2. to be continued..?

Installation

composer require chrgriffin/laravel-strict-validator

Usage

use ChrGriffin\StrictValidator;
 
$validator = new StrictValidator(
    $dataToValidate,
    [
        'foo'       => 'string|required',
        'bar'       => 'array|required',
        'bar.inner' => 'string|required'
    ]
);

$valid = $validator->validate();