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

"format" specifications ignored during validation #18

Open
JulesGosnell opened this issue Dec 29, 2020 · 0 comments
Open

"format" specifications ignored during validation #18

JulesGosnell opened this issue Dec 29, 2020 · 0 comments

Comments

@JulesGosnell
Copy link

JulesGosnell commented Dec 29, 2020

[jinx "0.1.6"]

I was hoping for a switch to enable this.

When I dug into the code, I found everything necessary to do it, but hooked up wrongly - validate/process-keyword is being called with document instance, rather than schema keys.

I've added this hack to our project to get it to work:

(do
;; tweak jinx:

(require '(juxt.jinx-alpha.validate))

;; warn us if we use an unknown format

(defmethod juxt.jinx-alpha.validate/check-format :default [fmt instance ctx]
(log/warn "unrecognised json schema format:" fmt instance))

;; force checking of a field's format - probably wrong but works

(defmethod juxt.jinx-alpha.validate/process-keyword :default [k value instance annotations ctx]
(when-let [f (and (map? value) (value "format"))]
(juxt.jinx-alpha.validate/process-keyword "format" f (instance k) annotations ctx))))

If I introduce a badly formatted value into my document and validate I now get an error message. It logs the entire object as 'instance'' rather than just the offending field, but it is better than nothing.

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