View Source Zoth.OpenId.Claim (Zoth v1.0.1)

Link to this section Summary

Functions

Return the value from the given source that is represented by the given claim.

Link to this section Types

@type standard_claim() :: :email | :email_verified
@type t() :: %Zoth.OpenId.Claim{
  alias: atom(),
  includes: [t()],
  name: standard_claim(),
  transformer: function() | nil,
  value_when_missing: any()
}

Link to this section Functions

Link to this function

get_value_for(claim, source)

View Source
@spec get_value_for(t(), source :: map()) :: t()

Return the value from the given source that is represented by the given claim.

options

Options

  • :alias - When you want to return a value from the source that's named differently

           than the claim you can specify it's name (alias). For example perhaps
           the source has more than one email and you want to return `work_email`
           as the value for `email`. Alias is ignored when `:transformer` is given.
  • :transformer - When passed a function it is executed with the given source

                 and the result of the function is used as the value for the claim.
                 You can specify a transformer when you wish to mutate a value into
                 something else or use a derived value.
  • :value_when_missing - Default is nil. You can specify a value to use when the

                        `source` does not have the specified attribute. This value
                        is ignored if you specify `:transformer`.
@spec new(attrs :: map()) :: t()