Skip to content

Add input validation #30

Open
Open
@denmch

Description

@denmch

I love this site, both because it's so attractive and easy to use, and because it allows me to test colors with alpha values. Thank you!

One thing I noticed while playing around with it, though, was that there's no indicator when a user enters an invalid color code. If the input is invalid, the last valid entry silently remains. If a user enters an invalid color, the new pairs seems to be just as the last valid pair.

For example, the page begins with:

white / hsla(200,0%,0%,.7)

If a user modifies the foreground number and misses a percent sign or pastes a malformed color code, output and #results remain unchanged, and the user may believe that their malformed color code is both valid and accessible, based on the unchanged success message.

For example, each of the following invalid foreground colors will appear to be successful:

white / hsla(200,0,0%,.7) (missing percent sign on saturation)
white / hsla(0%,0%,100%,0) (erroneous percent sign on hue)
white / bloop! (invalid color name)

Swapping the colors then fails because the invalid color code can't update the background color, so that both colors are now identical, i.e., reversing "white / bloop!" says "bloop! / white" but the actual colors being compared are "white / white."

I wasn't quite able to see how colors were being parsed, but it'd be great to work out validation for color codes so that users, especially those less familiar with how the different types are formed, can see where they've made mistakes in using the tool (e.g., it's easy for beginners to a percent sign, or confuse RGB and HSL).

Thanks.

(P.S.: I'd like to help out if I can, but I'm feeling a bit dense in trying to see how the inputs are parsed.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions