Zodish.Type.Optional (zodish v0.2.4)

View Source

Makes a given type optional, where you can also define a default value to be used when the value is nil.

Summary

Functions

Assigns a default value to be used when the value is either missing or nil. Alternatively, you can provide a zero-arity function or an MFA that should generate the default value.

Makes the given inner_type optional (either missing or nullable).

Types

t()

@type t() :: t(Zodish.Type.t())

t(inner_type)

@type t(inner_type) :: %Zodish.Type.Optional{
  default: inner_type | (-> inner_type) | mfa() | nil,
  inner_type: inner_type
}

Functions

default(type, value)

Assigns a default value to be used when the value is either missing or nil. Alternatively, you can provide a zero-arity function or an MFA that should generate the default value.

new(inner_type, opts \\ [])

Makes the given inner_type optional (either missing or nullable).