Skip to content

Commit

Permalink
Add Orchestra\Support\Validator::setRules() to override rules, and se…
Browse files Browse the repository at this point in the history
…t it as an instanceof Illuminate\Support\Fluent.

Signed-off-by: crynobone <[email protected]>
  • Loading branch information
crynobone committed Jun 22, 2013
1 parent e5fc175 commit 59f6562
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Orchestra/Support/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class Validator {
*/
public function __construct()
{
$this->rules = new Fluent($this->rules);
$this->setRules($this->rules);
}

/**
Expand Down Expand Up @@ -96,6 +96,9 @@ public function with($input, $events = array())
*/
protected function getBindedRules()
{
// If rules is not instance of \Illuminate\Support\Fluent, set it.
if ( ! $this->rules instanceof Fluent) $this->setRules($this->rules);

$rules = $this->rules;
$bindings = $this->prepareBindings('{', '}');

Expand Down Expand Up @@ -151,4 +154,16 @@ protected function runValidationEvents($events, $rules)
Event::fire($event, array( & $rules));
}
}

/**
* Set validation rules, this would override all previously defined
* rules.
*
* @access public
* @return void
*/
public function setRules($rules = array())
{
$this->rules = new Fluent($rules);
}
}

0 comments on commit 59f6562

Please sign in to comment.