Skip to content

Commit

Permalink
Fix rule validator
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Phoen committed Oct 19, 2015
1 parent 9e1f556 commit f5a1c2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Tests/Validator/Constraints/RuleValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function validRulesProvider()

$checkVariablesConstraint = new ValidRule([
'allowed_operators' => null, // all
'allowed_variables' => ['foo', 'bar']
'allowed_variables' => ['foo', 'bar', 'readingTime']
]);

return [
Expand All @@ -66,6 +66,7 @@ public function validRulesProvider()
['foo = 42 AND bar = foo', $checkOperatorsConstraint],

['foo = 42', $checkVariablesConstraint],
['readingTime <= 42', $checkVariablesConstraint],
['foo = 42 AND bar = foo', $checkOperatorsConstraint],
];
}
Expand Down
4 changes: 2 additions & 2 deletions Validator/Constraints/RuleValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private function validateOperators(Rule $model, Constraint $constraint)
}

$operators = array_map(function(AST\Operator $element) {
return $element->getName();
return strtolower($element->getName());
}, $model->getOperators());

foreach ($operators as $operator) {
Expand All @@ -67,7 +67,7 @@ private function validateVariableAccesses(Rule $model, Constraint $constraint)
$flattenedDimensions[] = $dimension[1];
}

return implode('.', $flattenedDimensions);
return strtolower(implode('.', $flattenedDimensions));
}, $model->getAccesses());

foreach ($accesses as $access) {
Expand Down

0 comments on commit f5a1c2b

Please sign in to comment.