View Source DataSchema.CastBehaviour behaviour (data_schema v0.5.0)

The casting function can either be a 1 arity function or a module that has a cast/1 function implemented. This behaviour is to help ensure that cast/1 function looks the way DataSchema expects.

Link to this section Summary

Callbacks

A doc should return an okay tuple with the casted value or an error tuple. For errors you can optionally provide a message that will be returned if DataSchema.to_struct/2 fails.

Link to this section Callbacks

Specs

cast(any()) :: {:ok, term()} | :error | {:error, term()}

A doc should return an okay tuple with the casted value or an error tuple. For errors you can optionally provide a message that will be returned if DataSchema.to_struct/2 fails.