-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Suggestion: modular CSS regex checks #1252
Comments
There's something that @hamzahejja did here, I don't know if it goes in line with what you are talking about? And how can we use it in the cases you mentioned? |
Thank you for pointing that out. I'll keep that in mind moving forward. I think that would serve as part of what I was suggesting to finally "glue" together the final regex pattern composed of re-usable, modular patterns. The re-usable patterns would be a set of globally available regex patterns (or I guess you can say sub-patterns) concerning a CSS This of course depends on the need for more CSS validators, which could be discussed here. |
I like the thinking 👍
./na
On Tue, Feb 25, 2020 at 12:26 PM Chris ***@***.***> wrote:
Thank you for pointing that out. I'll keep that in mind moving forward. I
think that would serve as part of what I was suggesting to finally "glue"
together the final regex pattern composed of re-usable, modular patterns.
The re-usable patterns would be a set of globally available regex patterns
(or I guess you can say sub-patterns) concerning a CSS <number>
<https://developer.mozilla.org/en-US/docs/Web/CSS/number> or <percentage>
<https://developer.mozilla.org/en-US/docs/Web/CSS/percentage> or <integer>
<https://developer.mozilla.org/en-US/docs/Web/CSS/integer>, or any other
CSS types/properties (there are some validators like isInt() as a
candidate for code reuse but I'm not sure if it validate a CSS-based
<integer>). Then when coding validators such as isHSL(), isRgbColor(),
and potentially other new CSS validators defined in validator.js, one can
use the available sub-patterns and combine them or augment them via
@hamzahejja <https://github.com/hamzahejja>'s function.
This of course depends on the need it for more CSS validators, which could
be discussed here.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1252?email_source=notifications&email_token=AAB7ZEKIXQPH4FKZ5INE2SDRETP2ZA5CNFSM4KZ3LXSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEM3GQDY#issuecomment-590768143>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB7ZEIWRNKQ525C7XMDUH3RETP2ZANCNFSM4KZ3LXSA>
.
--
Sent from a tiny device while on the move.
|
While working on PR #1159, I found myself constantly refining how I checked for the CSS
<number>
value and often having to replace the same pattern in multiple places of the larger regex pattern for theisHSL()
check. I realized I should have assembled the regex pattern in a modular way but then I thought this can be done at a more global level to support other CSS string validations (likeisRgbColor()
).As a possible "feature request" or development direction, maybe it would be good to make a collection of common regex patterns that we can use to build more complex patterns. This is particularly applicable to CSS checks for
isHSL()
andisRgbColor()
and other CSS-based checks which use the same<number>
,<percentage>
, and other value formats defined in the specification (see MDN documentation).Now I'm not an expert in JS, so I'm not sure what would be the best way to achieve a modular regex pattern. A quick Google search led me to this: https://stackoverflow.com/questions/185510/how-can-i-concatenate-regex-literals-in-javascript which I suppose could be one way to do it.
The text was updated successfully, but these errors were encountered: