Skip to content

Commit

Permalink
REturn false from validation when no rules exist
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Sep 23, 2017
1 parent 94db0fe commit 0bda6ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ public function run(array $data = null, string $group = null): bool

$this->loadRuleGroup($group);

// If no rules exist, we return false to ensure
// the developer didn't forget to set the rules.
if (empty($this->rules))
{
return false;
}

// Run through each rule. If we have any field set for
// this rule, then we need to run them through!
foreach ($this->rules as $rField => $ruleString)
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Validation/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public function testSetRulesStoresRules()

//--------------------------------------------------------------------

public function testRunReturnsTrueWithNothingToDo()
public function testRunReturnsFalseWithNothingToDo()
{
$this->validation->setRules([]);

$this->assertTrue($this->validation->run([]));
$this->assertFalse($this->validation->run([]));
}

//--------------------------------------------------------------------
Expand Down

0 comments on commit 0bda6ee

Please sign in to comment.