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

IntoSchema knows type and schemas for properties and children #414

Merged
merged 5 commits into from
Apr 20, 2021

Conversation

ikitommi
Copy link
Member

@ikitommi ikitommi commented Apr 10, 2021

Related to #269 & #270. Move methods from Schema to IntoSchema so that we can describe Malli schemas with Malli.

(defprotocol IntoSchema
  (-type [this] "returns type of the schema")
  (-type-properties [this] "returns schema type properties")
  (-properties-schema [this] "maybe returns :map schema describing schema properties")
  (-children-schema [this] "maybe returns sequence schema describing schema children")
  (-into-schema [this properties children options] "creates a new schema instance"))

the print-method now shows the :type:

(m/-enum-schema)
; => #IntoSchema{:type :enum}

(m/schema [*1 "A" "B"])
; => [:enum "A" "B"]

(type *1)
; => :malli.core/schema

@ikitommi ikitommi changed the title Type definitions IntoSchema knows type and schemas for properties and children Apr 10, 2021
@ikitommi ikitommi merged commit 7ce3567 into master Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant