View Source Appwrite.Consts.Browsers (appwrite v0.1.9)

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)

@spec is_valid_browser?(String.t()) :: boolean()

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

valid_browser(browser)

(macro)
@spec valid_browser(String.t()) :: boolean()

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)

@spec validate_browser(String.t()) :: {:ok, String.t()} | {:error, String.t()}

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)

@spec validate_browser!(String.t()) :: String.t()

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"