View Source Appwrite.Consts.Flag (appwrite v0.1.9)
Provides constants and validation functions for country flags.
This module defines the country flags by their ISO 3166-1 alpha-2 code and provides helper functions to validate them, ensuring only recognized country flags are used within the application.
Summary
Functions
Returns true if the given flag
is a valid country flag code.
Guard clause to check if a given flag
is a valid country flag code.
Validates the given flag
and returns {:ok, flag}
if it is valid,
or {:error, "Invalid country flag code"}
otherwise.
Returns the given flag
if it is valid. Raises an ArgumentError
if the flag
is invalid.
Functions
Returns true if the given flag
is a valid country flag code.
Examples
iex> Flag.is_valid_flag?("us")
true
iex> Flag.is_valid_flag?("xx")
false
Guard clause to check if a given flag
is a valid country flag code.
Examples
iex> Flag.valid_flag("in")
true
iex> Flag.valid_flag("xx")
false
Validates the given flag
and returns {:ok, flag}
if it is valid,
or {:error, "Invalid country flag code"}
otherwise.
Examples
iex> Flag.validate_flag("ca")
{:ok, "ca"}
iex> Flag.validate_flag("xx")
{:error, "Invalid country flag code"}
Returns the given flag
if it is valid. Raises an ArgumentError
if the flag
is invalid.
Examples
iex> Flag.validate_flag!("fr")
"fr"
iex> Flag.validate_flag!("xx")
** (ArgumentError) Invalid country flag code: "xx"