Created
August 12, 2013 12:25
-
-
Save alloyking/6210379 to your computer and use it in GitHub Desktop.
Laravel abstact validator
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 Services\Validators; | |
abstract class Validator { | |
protected $attributes; | |
public $errors; //allow access to error messages | |
public function __construct($attributes = null){ | |
$this->attributes = $attributes ?: \Input::all(); | |
} | |
public function passes(){ | |
$validation = \Validator::make($this->attributes, static::$rules, static::$messages); | |
if( $validation->passes() ) return true; | |
$this->errors = $validation->messages(); | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment