Validates color format values against their specification.
Supported Formats
hex:RRGGBB- 6 hexadecimal characters (0-9, A-F, a-f)rgb:R,G,B- Three integers 0-255argb:A,R,G,B- Alpha 255, then R,G,B 0-255xterm:N- Integer 0-255hsl:H,S,L- H: 0-360 (degrees, 2 decimals), S/L: 0-100 (percentage, 4 decimals)hsv:H,S,V- H: 0-360 (degrees, 2 decimals), S/V: 0-100 (percentage, 4 decimals)cmyk:C,M,Y,K- Each 0-100 (percentage, 4 decimals)
Usage
iex> Pote.Validator.validate("hex:FF0000")
:ok
iex> Pote.Validator.validate("rgb:256,0,0")
{:error, :rgb_value_out_of_range}
iex> Pote.Validator.validate("hsl:370,50,50")
{:error, :hue_out_of_range}
Summary
Functions
Returns a human-readable error message for a validation error.
Validates a color input string with format prefix.
Types
Functions
Returns a human-readable error message for a validation error.
@spec validate(String.t()) :: validation_result()
Validates a color input string with format prefix.
Returns :ok if all values are valid, or {:error, reason} or {:error, reason, detail} if not.