hazzard/validation

Use Illuminate Validation outside Laravel.

1.0.1 2016-02-03 16:31 UTC

This package is auto-updated.

Last update: 2024-11-14 05:34:28 UTC


README

Installation

composer require illuminate/validation

composer require hazzard/validation

Usage

use Hazzard\Validation\Validator;

$validator = new Validator;

// Set default language lines used by the translator.
$validator->setDefaultLines();

// Make instance available globally via static methods (optional).
$validator->setAsGlobal();

// Create a class alias (optional). 
$validator->classAlias();
Database Presence Verifier

Using the Illuminate Database Capsule set the database connection instance:

$db = $capsule->getDatabaseManager();

$validator->setConnection($db);
Providing A Custom Translator

To provide a custom translator pass an instance of Illuminate\Container\Container with the translator bound to translator.

The translator must implement Symfony\Component\Translation\TranslatorInterface.

$container['translator'] = new CustomTranslator();

$validator = new Validator($container);
Using The Validator
$validator = Validator::make(
    ['name' => 'Dayle'],
    ['name' => 'required|min:5']
);

The rest is the same as Laravel.