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

Derive and declare effective types for schemas #264

Open
ikitommi opened this issue Sep 25, 2020 · 2 comments
Open

Derive and declare effective types for schemas #264

ikitommi opened this issue Sep 25, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@ikitommi
Copy link
Member

ikitommi commented Sep 25, 2020

We should be able to both declare and derive/infer effective types for wrapper schemas like :and, :multi and :enum.

forked from #246. Replaces #39.

This is clearly also a :map

[:multi {:dispatch :type}
 [:sized [:map 
          [:type [:= :sized]] 
          [:size int?]]]
 [:human [:map 
          [:type [:= :human]] 
          [:name string?] 
          [:address [:map [:country keyword?]]]]]]

this is an :int

[:fn {:type :int} '(fn [x] (< 10 x 100))]

and this is a :keyword

[:enum :kikka :kakka :kukka]

this too

[:and keyword? keyword?]

and this

[:or keyword? [:fn {:type :keyword} '(fn [x] (keyword? x)]]
@ikitommi
Copy link
Member Author

working on this.

@dmcgillen
Copy link
Contributor

Hi. Just wondering, in #782 (which is closed and refers to this issue) support was added for:

(m/decode [:enum :A :B :C] "A" (mt/string-transformer)) ;; => :A

Is this "full solution" going to include support for going the other way? i.e.:

(m/encode [:enum :A :B :C] :A (mt/string-transformer)) ;; => "A"

or should I open a separate issue (or is there a reason it perhaps isn't going to be done)?

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 🏗 Doing
Development

No branches or pull requests

2 participants