ifnot/validation-parser

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (0.4.2.1) of this package.

Maintainers

Package info

github.com/Ifnot/ValidationParser

Issues

pkg:composer/ifnot/validation-parser

Statistics

Installs: 297

Dependents: 0

Suggesters: 0

Stars: 0

0.4.2.1 2016-04-27 10:11 UTC

This package is auto-updated.

Last update: 2020-02-05 23:05:00 UTC


README

Simple Laravel validation rule parser for : auto-generate forms, auto-generate documentations etc ... from a simple Laravel Validation array.

Compatible with Laravel 4 and Laravel 5

Installation

composer require "ifnot/validation-parser"

Custom usage

In this example we will call the RuleSet parser with a custom view for rendering an automatic Form.

In the Controller Action / Route, we define witch view using for each field :

Ifnot\ValidationParser\RuleSet::$view = 'my.form.field';
return View::make('my.form.show');

In /view/my/form/show.blade.php we loop on each RuleSets and bind the property to the RuleSet view.

@foreach([
  "email":"required|email",
  "civility":"required|in:M,F",
  "comment":"string"
] as $property => $rules)
  {{ \Ifnot\ValidationParser\RuleSet::parse($rules)->bind('property' => $property)->toString() }}
@endforeach

In the RuleSet view /views/my/form/field.blade.php (specified before) :

<label>{{ $property }}</label>
@if($ruleSet->isBoolean())
  {{-- Here insert a input type radio --}}
@elseif($ruleSet->isIn())
  {{-- Here, you can insert a select with $ruleSet['in']->params witch contains an array of allowed values --}}
@elseif($field->isExists())
  {{-- Here a ajax loaded json from your table $ruleSet['in']->params[0] and the column $ruleSet['in']->params[1] --}}
@endif