OAuthProvider (appwrite v0.1.1)
Provides constants and validation functions for OAuth providers.
This module defines various OAuth providers such as Amazon, Apple, GitHub, Google, and more.
Helper functions are included to validate these provider values, ensuring only recognized OAuth providers are used.
Summary
Functions
Returns true if the given provider is a valid OAuth provider.
Guard clause to check if a given provider is a valid image gravity code.
Validates the given provider and returns {:ok, provider} if it is valid,
or {:error, "Invalid OAuth provider"} otherwise.
Returns the given provider if it is valid. Raises an ArgumentError
if the provider is invalid.
Functions
is_valid_provider?(provider)
Returns true if the given provider is a valid OAuth provider.
Examples
iex> OAuthProvider.is_valid_provider?("google")
true
iex> OAuthProvider.is_valid_provider?("example")
false
@spec valid_provider(String.t()) :: boolean()
@spec valid_provider(String.t()) :: {:ok, String.t()} | {:error, String.t()}
Guard clause to check if a given provider is a valid image gravity code.
Examples
iex> OAuthProvider.valid_provider("google")
true
iex> OAuthProvider.valid_provider("xxx")
false
validate_provider(provider)
Validates the given provider and returns {:ok, provider} if it is valid,
or {:error, "Invalid OAuth provider"} otherwise.
Examples
iex> OAuthProvider.validate_provider("github")
{:ok, "github"}
iex> OAuthProvider.validate_provider("example")
{:error, "Invalid OAuth provider"}
validate_provider!(provider)
Returns the given provider if it is valid. Raises an ArgumentError
if the provider is invalid.
Examples
iex> OAuthProvider.validate_provider!("google")
"google"
iex> OAuthProvider.validate_provider!("example")
** (ArgumentError) Invalid OAuth provider: "example"