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

Provides constants and validation functions for different types of authenticators.

This module defines allowed authenticator types and provides helper functions to validate them. It is useful for ensuring that only recognized authenticator types are used within the application.

Summary

Functions

Returns true if the given type is a valid authenticator type, otherwise false.

Guard clause to check if a given type is a valid authenticator type.

Validates the given type and returns {:ok, type} if it is valid, or {:error, "Invalid authenticator type"} otherwise.

Validates the given type and returns it if it is valid. Raises an ArgumentError if the type is invalid.

Functions

is_valid_type?(type)

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

Returns true if the given type is a valid authenticator type, otherwise false.

Examples

iex> AuthenticatorType.is_valid_type?("totp")
true

iex> AuthenticatorType.is_valid_type?("unknown")
false

valid_type(type)

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

Guard clause to check if a given type is a valid authenticator type.

Examples

iex> AuthenticatorType.valid_type("totp")
true

iex> AuthenticatorType.valid_type("unknown")
false

validate_type(type)

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

Validates the given type and returns {:ok, type} if it is valid, or {:error, "Invalid authenticator type"} otherwise.

Examples

iex> AuthenticatorType.validate_type("totp")
{:ok, "totp"}

iex> AuthenticatorType.validate_type("unknown")
{:error, "Invalid authenticator type"}

validate_type!(type)

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

Validates the given type and returns it if it is valid. Raises an ArgumentError if the type is invalid.

Examples

iex> AuthenticatorType.validate_type!("totp")
"totp"

iex> AuthenticatorType.validate_type!("unknown")
** (ArgumentError) Invalid authenticator type: "unknown"