Skip to content

Commit

Permalink
Several identical consecutive rules. E.g. v::call()->call().
Browse files Browse the repository at this point in the history
  • Loading branch information
romeOz committed Mar 20, 2015
1 parent 5996262 commit 5017aaa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ public function validate($input)
*/
foreach($this->_rules as $ruleName => $rules){

if (!is_array($rules)) {
$rules = [$rules];
}
foreach($rules as $rule) {

// notOf or oneOf
Expand Down Expand Up @@ -416,27 +419,27 @@ protected function isEmpty($value, Rule $rule)
protected function attributesInternal($attributes)
{
$this->_rules = [];
$this->_rules['attributes'][0] = new Attributes(['attributes' => $attributes, 'valid' => $this->valid]);
$this->_rules['attributes'] = new Attributes(['attributes' => $attributes, 'valid' => $this->valid]);
return $this;
}

protected function oneOfInternal(Validate $validate)
{
$validate->one = true;
$this->_rules['oneOf'][0] = $validate;
$this->_rules['oneOf'] = $validate;
return $this;
}

protected function notOfInternal(Validate $validate)
{
$validate->valid = false;
$this->_rules['notOf'][0] = $validate;
$this->_rules['notOf'] = $validate;
return $this;
}

protected function whenInternal(Validate $if, Validate $then, Validate $else = null)
{
$this->_rules['when'][0] = new When(['if' => $if, 'then' => $then, 'else' => $else, 'valid' => $this->valid]);
$this->_rules['when'] = new When(['if' => $if, 'then' => $then, 'else' => $else, 'valid' => $this->valid]);
return $this;
}

Expand Down

0 comments on commit 5017aaa

Please sign in to comment.