-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Validator] Access container array in Expression/Context #23134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2aa3e7c
c6d83d5
9e0882b
c964fcb
53016a5
1907d8b
209c386
afd2406
26f4505
bd3abc9
5c849fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ private function getPropertyAccessor() | |
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccess')) { | ||
throw new RuntimeException('Unable to use expressions with data path as the Symfony PropertyAccess component is not installed.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should not throw this exception in the constraint to allow to detect this mistake earlier. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course we could throw it there. But than we need to check there if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that would be fine. |
||
} | ||
|
||
return PropertyAccess::createPropertyAccessor(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the exception in src/Symfony/Component/Validator/Constraints/Expression.php should be moved here IMHO: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather make the property There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made the property |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,9 +238,9 @@ public function testExpressionLanguageUsage() | |
|
||
public function testExpressionLanguageUsageWithCustomDataPath() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this name make sense? Maybe just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I orientated me on the naming from the test function above with name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I saw that. But the previous test actually tests that passing in a custom |
||
{ | ||
$constraint = new Expression(['expression' => 'value <= this["dateEnd"]', 'dataPath' => 'root[data]']); | ||
$constraint = new Expression(array('expression' => 'value <= this["dateEnd"]', 'dataPath' => 'root[data]')); | ||
|
||
$this->setRoot(['data' => ['dateEnd' => '2011-06-07', 'dateStart' => '2011-06-05']]); | ||
$this->setRoot(array('data' => array('dateEnd' => '2011-06-07', 'dateStart' => '2011-06-05'))); | ||
$this->setPropertyPath(''); | ||
$this->setProperty(null, 'property'); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use the
class
constant instead