metosin / metosin/schema-tools
Slicing schemas with partial values
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 110
- Forks
- 15
- Avg merge
- 6m
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the schema transformation code and the st/sub-schema entry point referenced in the issue, then compare its behavior with the s/defschema examples. Done means a function accepts a value and schema and returns the original schema with fields present in the value removed, including nested fields, producing the two shown results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100