Service Validation Package

1

I am developing a large project with Laravel and need to validate my data. Initially I had planned to use Ardent, but this is not compatible / advisable for anyone using the default repository.

So I'll have to do the services validations. Do you recommend any specific packages?

    
asked by anonymous 10.02.2014 / 20:45

1 answer

1

Implementing validation as a service:

I do not know a package, I suspect it does not yet exist.

But there are a couple of articles that contain exactly what you want:

link link

With the solution presented, you specify your validation rules as follows:

<?php namespace App\Service\Validation\Laravel;

use App\Service\Validation\ValidableInterface;

class UserCreateValidator extends LaravelValidator implements ValidableInterface {

  /**
   * Validação para criar um novo User
   *
   * @var array
   */
  protected $rules = array(
    'username' => 'required|min:2',
    'email' => 'required|email',
    'password' => 'required'
  );

}

The UserCreateValidator class inherits the basic functionality of the AbstractValidator class, the Laravel-specific functionality to run validation tests of the LaravelValidator class, and finally each child class completes the implementation with the specifically required rules. The implementation of ValidableInterface ensures that the class meets the contract requirements.

    
11.02.2014 / 02:37