使用命名空间限定的关键字和不存在的命名空间来定义规范是否被认为是错误的做法?我希望在公共域命名空间中定义实体映射..。因此,为了避免在合并规范时丢失数据,我使用了常规:entity/attribute,而不是::entity-attribute,用于属性和实体的标准::entity。它与数据库表和列对齐得更好。单独命名空间中的每个实体都让我想起了Java类,听起来不是个好主意。
(s/def :country/id ::nilable-nat-int)
(s/def :country/name ::non-empty-string)
(s/def ::country
(s/keys :req [:country/id
:country/name]))
;; ----------------------------------------
(s/def :location/id ::nilable-nat-int)
(s/def :location/name ::non-empty-string)
(s/def :location/zipcode ::nilable-non-empty-string)
(s/def ::location
(s/merge
(s/keys :req [:location/id
:location/name
:location/zipcode])
(s/or :country ::country
:country-id
(s/keys :req [:country/id]))))发布于 2018-11-14 01:22:39
https://stackoverflow.com/questions/53279505
复制相似问题