2017 © Pedro Peláez
 

library validator

Validator bassed on Laravel Validator, with support of translation.

image

kocal/validator

Validator bassed on Laravel Validator, with support of translation.

  • Sunday, July 16, 2017
  • by Kocal
  • Repository
  • 1 Watchers
  • 1 Stars
  • 78 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 10 % Grown

The README.md

Validator

Build Status, (*1)

A PHP values validator that makes you able to use the great Laravel Validator, but outside a Laravel project., (*2)

Installation

$ composer require kocal/validator

Usage

All Laravel validation rules except exists and unique are supported., (*3)

<?php
use Kocal\Validator\Validator;

$rules = ['field' => 'required|min:5'];
$data = ['field' => 'Validation'];

$validator = new Validator($rules);
$validator->validate($data);
$validator->passes(); // true
$validator->fails(); // false
$validator->errors()->toArray(); // returns array of error messages

Advanced usage

Translations

Available validation translation languages: see src/lang directory. The default language is fr., (*4)

<?php
use Kocal\Validator\Validator;

$validator = new Validator([], 'es');

Custom validation rule

<?php
use Kocal\Validator\Validator;

$validator = new Validator(['field' => 'is_foo']);

$validator->extend('is_foo', function ($attribute, $value, $parameters, $validator) {
    return $value == 'foo';
}, "Le champ :attribute n'est pas égal à 'foo'.");

$validator->validate(['field' => 'not_foo']);

The Versions

16/07 2017

dev-master

9999999-dev

Validator bassed on Laravel Validator, with support of translation.

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Hugo Alliaume

16/04 2017

v0.1.0

0.1.0.0

Validator bassed on Laravel Validator, with support of translation.

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Hugo Alliaume