Pote.Sanitizer (Pote v1.0.0)

Copy Markdown View Source

Handles cleaning user input for colour formats.

Its purpose is to strip unit symbols (%, º, deg) from numeric values so that format modules can parse them without errors.

Summary

Functions

Cleans a string by removing common unit suffixes. Examples

Cleans a list of strings or a delimiter-separated string. Useful for inputs like "360º, 50%, 50%".

Functions

sanitize(input)

@spec sanitize(String.t()) :: String.t()

Cleans a string by removing common unit suffixes. Examples:

  • "360º" -> "360"
  • "50%" -> "50"
  • "12.5 deg" -> "12.5"

sanitize_list(input, separator)

@spec sanitize_list(any(), String.t()) :: {:ok, [String.t()]} | :error
@spec sanitize_list([String.t()], nil) :: {:ok, [String.t()]} | :error

Cleans a list of strings or a delimiter-separated string. Useful for inputs like "360º, 50%, 50%".