Genesis.Value (genesis v0.7.0)

View Source

Summary

Functions

Casts attrs against the given props definition.

Checks that the given value can be used as a prop of type. Raises ArgumentError if the value does not match the type.

Defines a property for an Aspect.

Functions

cast(attrs, props)

Casts attrs against the given props definition.

ensure_type!(value, type)

Checks that the given value can be used as a prop of type. Raises ArgumentError if the value does not match the type.

prop(name, type, opts \\ [])

(macro)

Defines a property for an Aspect.

Examples

prop :name, :binary, required: true
prop :age, :integer, default: 0

The supported types are: :atom, :binary, :boolean, :datetime, :float, :integer, :pid, :ref.

Options

  • :required - when set to true, the property must be provided when creating or updating the aspect. Defaults to false.

  • :default - specifies a default value for the property if none is provided.

Validation

The property value is validated against its type when the aspect is created or updated. If the value does not match the type, an ArgumentError is raised.