-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Validator] Added CssColor constraint #14965
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
Conversation
fc18710
to
b21f21b
Compare
b21f21b
to
d301bfd
Compare
5e2c888
to
4a20f74
Compare
e9f296c
to
fa5743e
Compare
This PR was merged into the 5.4 branch. Discussion ---------- [Validator] Added `CssColor` constraint | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | symfony/symfony-docs#14965 This PR introduces a new `CssColor` constraint. It comes with 3 validation modes: - Long, which allows all hexadecimal representation of a color, or 9 (#EEEEEEFF) characters - Short, which only allows hexadecimal colors on 4 (#EEE), 5 (#FFF00) characters - Named colors, which matches [the official list of named colors](https://www.w3.org/TR/css-color-4/#named-color) - HTML5, which allows hexadecimal colors on 7 (#EEEEEE) characters as well as the HTML5 input type color I know that such a color validation already exists in Symfony (in the `ColorType` class), 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 added `CssColor` constraint. Let me know, if yes, I will make the change. Commits ------- b36371c Added new CssColor constraint
This PR was merged into the 5.4 branch. Discussion ---------- [Validator] Added `CssColor` constraint | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | symfony/symfony-docs#14965 This PR introduces a new `CssColor` constraint. It comes with 3 validation modes: - Long, which allows all hexadecimal representation of a color, or 9 (#EEEEEEFF) characters - Short, which only allows hexadecimal colors on 4 (#EEE), 5 (#FFF00) characters - Named colors, which matches [the official list of named colors](https://www.w3.org/TR/css-color-4/#named-color) - HTML5, which allows hexadecimal colors on 7 (#EEEEEE) characters as well as the HTML5 input type color I know that such a color validation already exists in Symfony (in the `ColorType` class), 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 added `CssColor` constraint. Let me know, if yes, I will make the change. Commits ------- b36371c06e Added new CssColor constraint
The feature PR has been merged. |
It needs some work here to report the last changes (modes instead of mode) from the code. |
f395714
to
10810ad
Compare
I don't understand why the CI fails 🤔 |
friendly ping @Nyholm can you help? |
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.
Some minor, afterwards good to merge
The CI is correct. The class is called “Constraint” https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Validator/Constraint.php |
Oh. Sorry. I see now that you import partial FQCN. Ci does not support that (appearently) Feel free to ignore that :) |
10810ad
to
70bcc38
Compare
70bcc38
to
fd57353
Compare
fd57353
to
fc1539c
Compare
Thanks Mathieu for working on this feature, this is much appreciated. |
…aviereguiluz) This PR was merged into the 5.4 branch. Discussion ---------- [Validator] Some tweaks to CssColor constraint This tweaks the great work made by `@welcoMattic` in symfony#14965. It's mostly minor tweaks ... but I also expanded the "basic usage" example to show the case of not adding any parameters to the constraint, which is a common case when you just want to allow any of the valid CSS color formats. Commits ------- 07e38b7 [Validator] Some tweaks to CssColor constraint
This PR introduces the new
CssColor
constraint, contributed in symfony/symfony#40168