Pote.Validator.Parser (Pote v3.0.0)

Copy Markdown View Source

Internal parser helpers used by Pote.Validator.

Splits out the numeric parsing (hue, percentage, normalized, decimals) from the format dispatch logic so that Pote.Validator remains a thin façade.

Not part of the public API — used only by Pote.Validator.

Summary

Functions

Parses a hue string (0-360 degrees, up to 2 decimal places).

Parses a normalized value (0.0-1.0, up to 2 decimal places).

Parses a percentage (0-100, up to 2 decimal places).

Validates that a string has at most max_decimals decimal places.

Functions

parse_hue(str)

@spec parse_hue(String.t()) :: {:ok, float()} | {:error, atom()}

Parses a hue string (0-360 degrees, up to 2 decimal places).

parse_normalized(str)

@spec parse_normalized(String.t()) :: {:ok, float()} | {:error, atom()}

Parses a normalized value (0.0-1.0, up to 2 decimal places).

parse_percentage(str)

@spec parse_percentage(String.t()) :: {:ok, float()} | {:error, atom()}

Parses a percentage (0-100, up to 2 decimal places).

valid_decimals?(str, max_decimals)

@spec valid_decimals?(String.t(), non_neg_integer()) :: boolean()

Validates that a string has at most max_decimals decimal places.