Skip to content

[Validator] Add option to pass custom values to Expression validator #25504

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

Merged
merged 1 commit into from
Jan 8, 2018

Conversation

ostrolucky
Copy link
Contributor

@ostrolucky ostrolucky commented Dec 15, 2017

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

I needed this in a Form. I had no way to pass things from $options into Expression validator.

Maybe can aid in #23134

@@ -30,6 +30,7 @@ class Expression extends Constraint

public $message = 'This value is not valid.';
public $expression;
public $values = array();
Copy link
Member

Choose a reason for hiding this comment

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

should it be named $variables?

Copy link
Contributor Author

@ostrolucky ostrolucky Dec 18, 2017

Choose a reason for hiding this comment

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

I've named it according to second argument in ExpressionLanguage::evaluate. If $variables is better name, maybe it's worth it to change it there too? What do you guys think?

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Dec 18, 2017
@ostrolucky ostrolucky force-pushed the expression-values branch 2 times, most recently from 1b489fc to 57d79b2 Compare December 30, 2017 16:00
@ostrolucky
Copy link
Contributor Author

ostrolucky commented Jan 4, 2018

Ping. Values or variables? Will change in ExpressionLanguage accordingly.

Vote by reacting with:
👍 variables
👎 values

@nicolas-grekas
Copy link
Member

I'm good with values also. Any other opinion?
(rebase needed)

@ostrolucky
Copy link
Contributor Author

Rebased.

More options for naming :

  1. context - used by Twig, hoa/ruler
  2. parameters - used by ControllerTrait::render
  3. environment - used in various places, most notably in Psr/LoggerInterface

Vote by reacting with:

👍: variables
👎: values
😆 : context
🎉 : parameters
❤️ : environment

@fabpot
Copy link
Member

fabpot commented Jan 8, 2018

Thank you @ostrolucky.

@fabpot fabpot merged commit ba0565e into symfony:master Jan 8, 2018
fabpot added a commit that referenced this pull request Jan 8, 2018
…sion validator (ostrolucky)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[Validator] Add option to pass custom values to Expression validator

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

I needed this in a Form. I had no way to pass things from `$options` into Expression validator.

Maybe can aid in #23134

Commits
-------

ba0565e [Validator] Add option to pass custom values to Expression validator
@fabpot fabpot mentioned this pull request May 7, 2018
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.

4 participants