diff --git a/src/wanijo/instance/domain.clj b/src/wanijo/instance/domain.clj index 74da9a1..b33fc38 100644 --- a/src/wanijo/instance/domain.clj +++ b/src/wanijo/instance/domain.clj @@ -65,16 +65,18 @@ SET p.value = {value}, p.created_at = {created_at}, p.updated_at = {updated_at}") -(defn create! [user-uuid schema-uuid instance] +(defn create! [user-uuid + schema-uuid + {:keys [name properties]}] (let [instance-uuid (neo4j/uuid) now (neo4j/now-str) instance-tuple [create-instance {:schema_uuid schema-uuid - :name (:name instance) + :name name :uuid instance-uuid :created_at now :user_uuid user-uuid}] - prop-tuples (for [{:keys [attribute value]} (:properties instance)] + prop-tuples (for [{:keys [attribute value]} properties] [create-property {:uuid instance-uuid :attr_uuid (:uuid attribute) diff --git a/src/wanijo/instance/forms.clj b/src/wanijo/instance/forms.clj index cb80220..9a1fa1d 100644 --- a/src/wanijo/instance/forms.clj +++ b/src/wanijo/instance/forms.clj @@ -1,10 +1,11 @@ (ns wanijo.instance.forms - (:require [wanijo.instance.domain :as domain])) + (:require [wanijo.specs :as specs] + [wanijo.instance.domain :as domain])) (def form {:fields {:name {:label "Name" :required true - :spec ::domain/name}}}) + :spec ::specs/req-name}}}) (defn link-form [instances] {:fields {:name {:label "Name"} diff --git a/src/wanijo/specs.clj b/src/wanijo/specs.clj index 3bdc488..72baf25 100644 --- a/src/wanijo/specs.clj +++ b/src/wanijo/specs.clj @@ -7,6 +7,8 @@ (spec/def ::created-at (spec/and string? ::neo4j/date-str)) (spec/def ::name string?) +(spec/def ::req-name + (spec/and ::name (complement empty?))) (spec/def ::instance_uuid ::neo4j/uuid) (spec/def ::attribute_uuid ::neo4j/uuid) (spec/def ::now ::neo4j/date-str)