hazzardweb / validation by cretueusebiu

Use Illuminate Validation outside Laravel.
378
2
3
Package Data
Maintainer Username: cretueusebiu
Maintainer Contact: cretu.eusebiu@gmail.com (Cretu Eusebiu)
Package Create Date: 2015-08-03
Package Last Update: 2017-10-20
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-09 15:03:23
Package Statistics
Total Downloads: 378
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 3
Total Forks: 3
Total Open Issues: 3

Illuminate Validation Outside Laravel

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.