Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Validator] AddedCssColor constraint#40168
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
74700e0 tofc3a5efComparefc3a5ef toed5f06dComparenorkunas commentedFeb 12, 2021
Why only hex? Maybe Color constraint with hex, rgb(a),hsl(a) support would be better :) |
welcoMattic commentedFeb 12, 2021
@norkunas Yes, I thought about it. But I was not sure if we have to support hex,rgb(a),hsl(a) in the same Constraint. I think that we should make separate Constraints to avoid to guess the format. WDYT? |
norkunas commentedFeb 12, 2021
Also good idea :) |
javiereguiluz commentedFeb 12, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Actually, CSS 4 defines four kinds of hexadecimal colors (https://www.w3.org/TR/css-color-4/#typedef-hex-color):
|
src/Symfony/Component/Validator/Constraints/HexaColorValidator.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
fancyweb commentedFeb 12, 2021
Interesting previous discussions on#35626 |
OskarStark commentedFeb 12, 2021
I would prefer HexColor instead of HexaColor |
src/Symfony/Component/Validator/Tests/Constraints/HexaColorValidatorTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
javiereguiluz commentedMay 25, 2021
Here are some comments in case we want to move this forward:
|
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedJul 4, 2021
@welcoMattic How can we move forward? |
welcoMattic commentedJul 4, 2021
@fabpot I intend to apply Javier's comments, and make a first version of this constraint that we can improve later following user's needs. |
cf0bba7 tocead49aComparewelcoMattic commentedJul 4, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I addressed@javiereguiluz's comments about making a first usable version of CssColor Constraint, with common formats support, which are:
Let me know if we are agree on this 1st version |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Tests/Constraints/CssColorTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
0eae445 to454d531CompareUh oh!
There was an error while loading.Please reload this page.
javiereguiluz left a comment
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.
Mathieu, you've done a fantastic job here. This constraint is much more complete than I imagined. It's great!
I left some minor comments ... and I also wonder ifmodes is the best word to describe the different types of CSS colors allowed by the constraint. I can't suggest a better alternative, butmodes doesn't feel 100% correct to me.
Thanks!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Resources/translations/validators.en.xlf OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
welcoMattic commentedSep 29, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@javiereguiluz thanks! About status: needs review |
347b2a1 to781598aComparea741651 to23709e7CompareUh oh!
There was an error while loading.Please reload this page.
23709e7 to8925155Compare8925155 tob36371cComparewelcoMattic commentedSep 30, 2021
Fabbot is wrong about the italian typo correction, it's |
welcoMattic commentedOct 6, 2021
@javiereguiluz@derrabus I don't know exactly when the feature freeze will happen, but I think this PR is ready to be merged in 5.4. |
derrabus commentedOct 6, 2021
I agree, this PR is ready. But I need a second approval to merge a feature PR. |
fabpot commentedOct 6, 2021
Thank you@welcoMattic. |
This PR was merged into the 5.4 branch.Discussion----------[Validator] Added CssColor constraintThis PR introduces the new `CssColor` constraint, contributed insymfony/symfony#40168Commits-------fc1539c Added CssColor constraint
| */ | ||
| publicfunction__construct($formats,string$message =null,array$groups =null,$payload =null,array$options =null) | ||
| { | ||
| $validationModesAsString =array_reduce(self::$validationModes,function ($carry,$value) { |
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.
Hi, I'm reading this PR and wondering if it wouldn't be a good idea to type things as much as we can when doing a chance?
Since Symfony 6 has better typing support, wouldn't it be a good idea to require adding typing when submitting a PR ?
Thanks
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.
It could be great, but in this case I made a little mistake, thisarray_reduce is overengineered, it has to be aimplode call.
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.
Looking at it twice now, and indeed, it could be replace with an implode :)
Uh oh!
There was an error while loading.Please reload this page.
This PR introduces a new
CssColorconstraint. It comes with 3 validation modes:I know that such a color validation already exists in Symfony (in the
ColorTypeclass), but it's hardcoded in the FormType, and not usable as an assert Annotation. We could decide to remove this hardcoded validation in favor of the new addedCssColorconstraint. Let me know, if yes, I will make the change.