Estructura.Coercer behaviour (estructura v1.11.0)

View Source

Behaviour for coercion delegates. Instead of implementing the coercion handlers in Estructura.Nested inplace, one might do

coerce do
  defdelegate foo.bar.created_at(value), to: :date
end

Available coercers out of the box:

  • Estructura.Coercers.Atom
  • Estructura.Coercers.Date
  • Estructura.Coercers.DateTime
  • Estructura.Coercers.Float
  • Estructura.Coercers.Integer
  • Estructura.Coercers.Time
  • Estructura.Coercers.NullableDate
  • Estructura.Coercers.NullableDatetime
  • Estructura.Coercers.NullableFloat
  • Estructura.Coercers.NullableInteger
  • Estructura.Coercers.NullableTime

Summary

Callbacks

Coerces the input value to the type handled by a respective coercer

Callbacks

coerce(value)

@callback coerce(value) :: {:ok, value} | {:error, any()} when value: term()

Coerces the input value to the type handled by a respective coercer