2017 © Pedro Peláez
 

library validator

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

image

cals/validator

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  • Wednesday, July 4, 2018
  • by Cals
  • Repository
  • 1 Watchers
  • 0 Stars
  • 40 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 5 % Grown

The README.md

Validator

Build Status Scrutinizer Code Quality Code Coverage Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Validator is designed for Laravel when use ajax. Validator is a simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel, which excepted validating data easier., (*2)

Install

You can simply install Validator use composer., (*3)

composer require cals/validator

And then add the Cals\Validator\ValidatorServiceProvider::class to your config/app.php providers array., (*4)

Cals\Validator\ValidatorServiceProvider::class

If you use Laravel 5.5 and after, you don't need do it cause laravel will auto load the provider., (*5)

Configuration

You have to publish the config using this command:, (*6)

php artisan vendor:publish --tag="validator"

You should put your rules and messages in it., (*7)

Usage

Validator provides a simple way to validate data, you can simply use it anywhere you want., (*8)

validate(array $values = [], $resource, array $messages = [], $sometimes = false), (*9)

$values is the data you wish to validate, $resource is one of your key in rules which contained in validator.php. And you can set messages while validating fails to return by using $message.When $sometimes was true, rules in sometimes would be used., (*10)

When validate failed, Validator will send a json response automatically.The returned data is like this., (*11)

{
    "errors": {
        "username": [
            "用户名不能为空"
        ],
        "password": [
            "密码不能是字母、数字、破折号和下划线之外的其他字符",
            "密码必须在 6 到 18 位之间"
        ]
    }
}

Example

Validator suggest using like this., (*12)

<?php

namespace App\Http\Controllers;

use Cals\Validator\AjaxValidator;
use Illuminate\Http\Request;

class ExampleController extends Controller
{
    private $validator;

    public function __construct(AjaxValidator $validator)
    {
        $this->validator = $validator;
    }

    public function index(Request $request)
    {
        $values = $request->all();
        $this->validator->validate($values,'user');
    }
}

License

The Validator is open-sourced library licensed under the MIT license., (*13)

The Versions

04/07 2018

dev-master

9999999-dev

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

04/07 2018

v0.3

0.3.0.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

04/07 2018

v1.0.1

1.0.1.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

06/06 2017

v1.0

1.0.0.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

21/04 2017

v0.2.7

0.2.7.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

23/01 2017

v0.2.6

0.2.6.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

26/12 2016

v0.2.5

0.2.5.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

15/12 2016

v0.2.4

0.2.4.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

15/12 2016

v0.2.3

0.2.3.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

15/12 2016

v0.2.2

0.2.2.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

15/12 2016

v0.2.1

0.2.1.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

13/12 2016

v0.2.0

0.2.0.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Avatar Cals

13/12 2016

v0.1

0.1.0.0

A simple encapsulation of Illuminate\Contracts\Validation\Factory in Laravel.

  Sources   Download

MIT

by Avatar Cals