WIP: validate required fields
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Moritz 2025-06-02 22:41:04 +02:00
parent 967a89b18d
commit 156cdb24d0
Signed by: moritz
GPG key ID: 1020A035E5DD0824
5 changed files with 62 additions and 4 deletions

View file

@ -9,14 +9,28 @@ defmodule Mv.Membership.Property do
end
actions do
defaults [:create, :read, :update, :destroy]
defaults [:read, :destroy]
default_accept [:value, :member_id, :property_type_id]
create :create_property do
primary? true
load [:property_type]
end
update :update_property do
primary? true
require_atomic? false
load [:property_type]
end
end
attributes do
uuid_primary_key :id
attribute :value, :union,
allow_nil?: true,
constraints: [
storage: :type_and_value,
types: [
@ -39,4 +53,15 @@ defmodule Mv.Membership.Property do
calculations do
calculate :value_to_string, :string, expr(value[:value] <> "")
end
aggregates do
first :property_type_required,
:property_type,
:required
end
validations do
validate {Mv.Membership.Validations.ValidateProperty, attribute: :value}
end
end