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

:not humanizer #1138

Merged
merged 1 commit into from
Dec 8, 2024
Merged

:not humanizer #1138

merged 1 commit into from
Dec 8, 2024

Conversation

frenchy64
Copy link
Collaborator

@frenchy64 frenchy64 commented Nov 26, 2024

This seems like a cheap and easy trick to automatically get a :not humanizer for most (simple) schemas.

Before supporting negated composite schemas we need to enhance humanizing to distinguish between conjunctions and disjunctions. Then we can leverage this for explaining negations:

;; should be [:and "should be a string" "should be a symbol"]
(me/humanize (m/explain [:and :string :symbol] nil))
;=> ["should be a string" "should be a symbol"]

;; should be [:or "should be a string" "should be a symbol"]
(me/humanize (m/explain [:or :string :symbol] nil))
;=> ["should be a string" "should be a symbol"]

@frenchy64 frenchy64 marked this pull request as ready for review November 26, 2024 22:18
@frenchy64 frenchy64 marked this pull request as draft November 27, 2024 00:04
@frenchy64 frenchy64 marked this pull request as ready for review November 27, 2024 00:58
@frenchy64 frenchy64 self-assigned this Nov 27, 2024
@frenchy64 frenchy64 requested a review from ikitommi November 27, 2024 00:58
Copy link
Member

@ikitommi ikitommi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's clever. Great tests!

@ikitommi ikitommi merged commit f8a7308 into metosin:master Dec 8, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants