Browser (appwrite v0.1.1)
Provides constants and validation functions for different browser types.
This module defines the allowed browser types and provides helper functions to validate them, ensuring only recognized browser types are used within the application.
Summary
Functions
Returns true if the given browser type is valid, otherwise false.
Guard clause to check if a given browser type is valid.
Validates the given browser type and returns {:ok, browser} if it is valid,
or {:error, "Invalid browser type"} otherwise.
Validates the given browser type and returns it if it is valid. Raises an
ArgumentError if the browser type is invalid.
Functions
is_valid_browser?(browser)
Returns true if the given browser type is valid, otherwise false.
Examples
iex> Browser.is_valid_browser?("ff")
true
iex> Browser.is_valid_browser?("unknown")
false
Guard clause to check if a given browser type is valid.
Examples
iex> Browser.valid_browser("ch")
true
iex> Browser.valid_browser("unknown")
false
validate_browser(browser)
Validates the given browser type and returns {:ok, browser} if it is valid,
or {:error, "Invalid browser type"} otherwise.
Examples
iex> Browser.validate_browser("ch")
{:ok, "ch"}
iex> Browser.validate_browser("unknown")
{:error, "Invalid browser type"}
validate_browser!(browser)
Validates the given browser type and returns it if it is valid. Raises an
ArgumentError if the browser type is invalid.
Examples
iex> Browser.validate_browser!("sf")
"sf"
iex> Browser.validate_browser!("unknown")
** (ArgumentError) Invalid browser type: "unknown"