Skip to content
New issue

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

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

Already on GitHub? # to your account

Add schema validation error highlight #383

Merged
merged 2 commits into from
Mar 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [Unreleased] 1.1.4
* Highlights schema validation errors

## 1.1.3
* Make fn validation customizable by addition of `fn-validator` function

Expand Down
4 changes: 2 additions & 2 deletions src/clj/schema/macros.clj
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
@~input-checker-sym
args#)
(when-let [error# (@~input-checker-sym args#)]
(error! (utils/format* "Input to %s does not match schema: %s"
(error! (utils/format* "Input to %s does not match schema: \n\n\t \033[0;33m %s \033[0m \n\n"
'~fn-name (pr-str error#))
{:schema ~input-schema-sym :value args# :error error#})))))
(let [o# (loop ~(into (vec (interleave (map #(with-meta % {}) bind) bind-syms))
Expand All @@ -251,7 +251,7 @@
@~output-checker-sym
o#)
(when-let [error# (@~output-checker-sym o#)]
(error! (utils/format* "Output of %s does not match schema: %s"
(error! (utils/format* "Output of %s does not match schema: \n\n\t \033[0;33m %s \033[0m \n\n"
'~fn-name (pr-str error#))
{:schema ~output-schema-sym :value o# :error error#}))))
o#))))
Expand Down