CommandedAggregateless. StructValidation
(commanded_aggregateless v1.0.0)
Copy Markdown
Provides a default validate/1 function for structs using Vex
Summary
Types
@type validation_result(struct_type) :: CommandedAggregateless.result( struct_type, CommandedAggregateless.StructValidation.ValidationError.t() )
Functions
@spec new(Enum.t() | struct(type), type) :: CommandedAggregateless.result( struct(type), CommandedAggregateless.StructValidation.ValidationError.t() ) when type: atom()
Builds a new struct with the given attributes and type then validates it using Vex
Returns {:ok, struct} if the struct is valid, otherwise {:error, errors}
where errors is a keyword list with keys being the invalid fields and the
values being keyword lists of the validation errors for that field.
@spec validate(struct_type) :: validation_result(struct_type) when struct_type: struct()
Validates the given struct using Vex
Returns {:ok, struct} if the struct is valid, otherwise {:error, errors}
where errors is a keyword list with keys being the invalid fields and the
values being keyword lists of the validation errors for that field.