Skip to content

Instantly share code, notes, and snippets.

@sahibalejandro
Last active August 29, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sahibalejandro/7c801a7d3b380a6758b3 to your computer and use it in GitHub Desktop.
Save sahibalejandro/7c801a7d3b380a6758b3 to your computer and use it in GitHub Desktop.
Class InputValidator
<?php namespace Acme\Validators;
use Validator;
/**
* Class InputValidator
* @package Acme\Validators
*/
abstract class InputValidator {
/**
* @var
*/
private $validator;
/**
* @var array
*/
protected $rules = [];
/**
* @var array
*/
protected $messages = [];
/**
* @param $input
* @throws InputValidatorException
*/
public function validate($input)
{
$this->validator = Validator::make($input, $this->rules, $this->messages);
if ($this->validator->fails()) {
throw new InputValidatorException($this->validator->messages());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment