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

Support for s/keys :req-un style syntax #852

Open
jasonjckn opened this issue Feb 11, 2023 · 1 comment
Open

Support for s/keys :req-un style syntax #852

jasonjckn opened this issue Feb 11, 2023 · 1 comment

Comments

@jasonjckn
Copy link
Contributor

jasonjckn commented Feb 11, 2023

New feature to mirror syntax (s/keys :req-un [::a])

At the moment, :map schema type \w qualified keywords won't validate any unqualified keywords, to compensate you have to write [:a ::foo/a], e.g.

(m/validate [:map [:a ::foo/a]] {:a value}) ;; => true

Would it make sense to add a new schema type :map-un such that

(m/validate [:map-un [::foo/a]] {:a value})  ;; => true

( Or perhaps add a new property somewhere, e.g. )

(m/validate [:map {:qualification-optional? true} [::foo/a]] {:a value})  ;; => true

If you go with the :map-un idea, its coercion implementations could transform unqualified keys into qualified keys.

It might seem like a superficial change, why not just write [:a ::foo/a], but it makes rich hickey's philosophy around specifications much more idiomatic. While malli is a superior to clojure.spec in many ways, the philosophy behind it is still state of the art.

Just an idea... feel free to close...

@knubie
Copy link

knubie commented Nov 14, 2023

Using a property feels more malli-esque. It would make it easy to update an existing schema to accept unqualified keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🇰‍🇼 Waiting
Development

No branches or pull requests

2 participants