library laravel-schemarequest
Server side form validation using JSON Schema
punkrockio/laravel-schemarequest
Server side form validation using JSON Schema
- Thursday, April 27, 2017
- by mitni455
- Repository
- 2 Watchers
- 1 Stars
- 0 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 1 Forks
- 0 Open issues
- 1 Versions
- 0 % Grown
laravel-schemarequest
Server side form validation using JSON Schema, (*1)
How to use
- Create a form request class as you would with artisan: php artisan make:request PersonRequest
- Change the extended class in PersonRequest to use SchemaRequest/SchemaFormRequest
- Implement the rules() method to return a JSON Schema string
Example, (*2)
<?php
namespace App\Http\Requests;
use SchemaRequest\SchemaFormRequest as Request;
class PersonFormRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return '{
"type": "object",
"properties": {
"fname": {"type": "string", "maximum": 5},
"lname": {"type": "string", "minimum": 5},
"mname": {"type": "string", "minimum": 5},
"age": {"type": "integer", "minimum": 21},
"email": {"type": "string", "format": "email"}
}
}';
}
}
dev-master
9999999-dev
Server side form validation using JSON Schema
Sources
Download
MIT
The Requires
The Development Requires
by
Aaron Bullard