Skip to content

Instantly share code, notes, and snippets.

@alloyking
Created August 12, 2013 12:25
Show Gist options
  • Save alloyking/6210379 to your computer and use it in GitHub Desktop.
Save alloyking/6210379 to your computer and use it in GitHub Desktop.
Laravel abstact validator
<?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