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

Slicing schemas with partial values #19

Open
ikitommi opened this issue Sep 27, 2015 · 0 comments
Open

Slicing schemas with partial values #19

ikitommi opened this issue Sep 27, 2015 · 0 comments

Comments

@ikitommi
Copy link
Member

additional schema transformation function, which takes in an value and a schema and returns a new Schema, which is a sub-schema of the original, having all the fields that we not present in the value.

(s/defschema Order
  {:id s/Str
   :type (s/enum :take-away :normal)
   :address {:street s/Str
             :zip s/Str}})

(st/sub-schema 
  {:id "123", 
   :address {:street "Aleksis Kiven katu 24 B 37"}})
; => {:type (s/enum :take-away :normal), :address {:zip s/Str})

(st/sub-schema 
  {:id "123", 
   :type :take-away 
   :address {:street "Aleksis Kiven katu 24 B 37"
             :zip "33200"}})
; => {}

Would be utterly cool with data-driven forms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant