Created
January 5, 2016 15:48
-
-
Save PhillipMwaniki/7e0c33bb6ca44f212a15 to your computer and use it in GitHub Desktop.
Validator Service for Laravel 4.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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