Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zen properties are being validated on any map #48

Open
KGOH opened this issue Jan 19, 2023 · 1 comment
Open

zen properties are being validated on any map #48

KGOH opened this issue Jan 19, 2023 · 1 comment

Comments

@KGOH
Copy link
Contributor

KGOH commented Jan 19, 2023

For some reason zen tries to valiadate properties on all data coming in, this can be illustrated on a map:
I expect to get error that :zen/tags is not a valid key defined for my map, but I get no errors instead. After I can pass a hash set of symbols it is apparent that it is being validated by the 'zen/tags schema.

  (def ztx (zen.core/new-context {}))

  (zen.core/load-ns ztx '{:ns myns foo {:zen/tags #{zen/schema}
                                        :type zen/map
                                        :keys {:foo {:type zen/string}}}})

  (zen.core/validate ztx #{'myns/foo} {:zen/tags "foo"})
  ;; => {:errors [], :warnings [], :effects []}

  (zen.core/validate ztx #{'myns/foo} {:zen/tags #{'myns/foo}})
  ;; => {:errors
  ;;     [{:message
  ;;       "Expected symbol 'myns/foo tagged with '#{zen/tag}, but only #{zen/schema}",
  ;;       :type "symbol",
  ;;       :path [:zen/tags myns/foo],
  ;;       :schema [myns/foo :property :zen/tags :every myns/foo :tags]}],
  ;;     :warnings [],
  ;;     :effects []}
@KGOH
Copy link
Contributor Author

KGOH commented Jan 19, 2023

Another interesting case:

(zen.core/validate ztx #{'myns/foo} {:zen/tags ["hello"]})
;; => {:errors
;;     [{:message "Expected type of 'symbol, got 'string",
;;       :path [:zen/tags "hello"],
;;       :type "symbol.type",
;;       :schema [myns/foo :property :zen/tags :every "hello" :type]}
;;      {:message "No symbol 'hello found",
;;       :type "string",
;;       :path [:zen/tags "hello"],
;;       :schema [myns/foo :property :zen/tags :every "hello" :tags]}],
;;     :warnings [],
;;     :effects []}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant