Added isValid function#633
Conversation
✅ Deploy Preview for colorjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Hi there @caoimghgin, thanks for submitting a PR!
I think a helper for this makes sense, but we absolutely cannot replicate all color parsing logic in it. The helper should most likely just call parse() and catch any thrown errors, i.e. a much, much smaller thing 😁
And since it would be calling the existing parse() machinery, it won't need that many tests either.
In terms of naming, I'd probably call it isColor(). isValid() makes sense in context, but when folks import it and use it throughout their code (which may do other things too), isValid() is less clear (is valid what?). And when used as a static method, it follows the Array.isArray() pattern too.
I'm also not sure what apps/tracer.js is for?
|
Thank you for contributing! |
Would be good to have an isValid helper #316 is needed to prevent crashes as users are typing where we want the UI to update upon valid entry dynamically.