Skip to content

Instantly share code, notes, and snippets.

@PhillipMwaniki
Created January 5, 2016 15:48
Show Gist options
  • Save PhillipMwaniki/7e0c33bb6ca44f212a15 to your computer and use it in GitHub Desktop.
Save PhillipMwaniki/7e0c33bb6ca44f212a15 to your computer and use it in GitHub Desktop.
Validator Service for Laravel 4.2
<?php
namespace Acme\Services;
use Validator as V;
use models;
class Validator {
protected $errors;
public function validate($input, $rules)
{
$validator = V::make($input, $rules);
if ($validator->fails())
{
$this->errors = $validator->messages();
return false;
}
return true;
}
public function errors()
{
return $this->errors;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment