-
Notifications
You must be signed in to change notification settings - Fork 216
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
Feature: extend-protocol IntoSchema for java.lang.Class and protocols #961
Comments
You can already add Class -> Schema via registry: (m/validate [:tuple String Long]
["123" 123]
{:registry (merge (m/default-schemas)
{String (m/-string-schema)
Long (m/-int-schema)})})
; => true |
... supporting classes out of the box would be nice, but not sure then there would be at least 3 ways to describe a string:
not sure if this makes the library easier to use. |
... maybe there should be a (m/validate [:maybe [:instance datomic.db.Db]] my-db) ;; => true |
When I started down this path, i was hoping to handle ALL classes, interfaces & protocols out-of-the-box e.g.
But protocols don't have their own Class to dispatch off of, rather are persistent data structures, and
Seems a bit janky, given all that, so i'm a lot less enthusiastic my original idea Also, to your point about the performance of I can send a PR for that if you'd like... but since this is so close to "You can already add Class -> Schema via registry"
|
going to close this, while i'm going to commit this code to my own codebase, i don't feel like it's worthy of malli codebase yet... still needs hammock time for supporting all of classes, interfaces, protocols, etc — not just classes. Please see #960 though, i'm still interested in the capability of -being able to do this-. |
It would be nice if I could write code like
(or likewise for protocols.)
and it would just work out of the box .
If someone can confirm this is an acceptable feature, i'll write a PR.
e.g. ............ (work in progress) any early feedback?
protocols might be more challenging TBD.
The text was updated successfully, but these errors were encountered: