View Source Ash.Type.Struct (ash v3.4.37)
Represents a struct.
Use the instance_of
constraint to specify that it must be an instance of a specific struct.
This cannot be loaded from a database unless the instance_of
constraint is provided.
If not, it can only be used to cast input, i.e for arguments.
Constraints
:instance_of
(atom/0
) - The module the struct should be an instance of:preserve_nil_values?
(boolean/0
) - If set to true, when storing, nil values will be kept. Otherwise, nil values will be omitted. The default value isfalse
.:fields
(keyword/0
) - The types of the fields in the struct, and their constraints.
For example:fields: [ amount: [ type: :integer, constraints: [ max: 10 ] ], currency: [ type: :string, allow_nil?: false, constraints: [ max_length: 3 ] ] ]
allow_nil? is true by default