Skip to content
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

[Validator] use "allowedVariables" to configure the ExpressionLanguageSyntax constraint #37009

Merged
merged 1 commit into from May 30, 2020

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented May 30, 2020

Q A
Branch? 5.1
Bug fix? no
New feature? no
Deprecations? no
Tickets Fix symfony/symfony-docs#13669
License MIT
Doc PR

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Just a naming suggestion.

@@ -29,8 +29,7 @@ class ExpressionLanguageSyntax extends Constraint

public $message = 'This value should be a valid expression.';
public $service;
public $validateNames = true;
public $names = [];
public $variableNames = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$allowedVariables would be better to me (as suggested in the linked doc issue btw)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, and shouldn't the default be null, to allow any variables?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the suggested name sounds better to me. I am going to change that.

My reasoning for the empty array as the default value was that allowing arbitrary names rather looks like an edge case to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not allowing any variables by default means allowing only static expressions, isn't it? Since static expressions are never why ppl use EL, this would effectively force ppl to be explicit all the time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied the suggested changes while merging, please tell if you think this is a mistake :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. :) Thanks!

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution! I agree with Nico's comments, but overall it looks OK.

@nicolas-grekas nicolas-grekas changed the title [Validator] drop the validateNames option [Validator] use "allowedVariables" to configure the ExpressionLanguageSyntax constraint May 30, 2020
@nicolas-grekas
Copy link
Member

Thank you @xabbuh.

@nicolas-grekas nicolas-grekas merged commit af444f8 into symfony:5.1 May 30, 2020
@xabbuh xabbuh deleted the pr-35849 branch May 31, 2020 03:56
@fabpot fabpot mentioned this pull request May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants