Is there a way to validate a colour string?
ziofat opened this issue · comments
I got a crash when my user input #0
for colour.
Regex might be your best bet if you're looking for something easy!
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.
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.