View Source Appwrite.Consts.OAuthProvider (appwrite v0.1.7)

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

Link to this function

is_valid_provider?(provider)

View Source
@spec is_valid_provider?(String.t()) :: boolean()

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
Link to this macro

valid_provider(provider)

View Source (macro)
@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
Link to this function

validate_provider(provider)

View Source

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"}
Link to this function

validate_provider!(provider)

View Source
@spec validate_provider!(String.t()) :: String.t()

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"