Skip to content
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

Is there a way to validate a colour string? #50

Open
ziofat opened this issue Dec 2, 2020 · 3 comments
Open

Is there a way to validate a colour string? #50

ziofat opened this issue Dec 2, 2020 · 3 comments

Comments

@ziofat
Copy link

ziofat commented Dec 2, 2020

I got a crash when my user input #0 for colour.

@ncovercash
Copy link

Regex might be your best bet if you're looking for something easy!

@ncovercash
Copy link

A simple ^#[0-9a-f]{3}|[0-9a-f]{6}$ should suffice to validate a hex color; if you want only full six-digit hex colors, ^#[0-9a-f]{6}$ is all it would take.

@ziofat
Copy link
Author

ziofat commented Dec 4, 2020

hex can be easy. What about other format?
I did solved my problem by using regex and I am thinking about a universal validator for all colour format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants