Skip to content

Completely new approach to specifying schemas #11

@radix

Description

@radix

Schema choice Done

Replaces top-level when_key_is, when_key_exists, when_tag_is, and choose_schema?

{
  "choose_schema": {
    "when_key_is": {
      "key": "type",
      "choices": {
        "foo": {...},
        "bar": {...},
      }
    }
  }
}

choose_schema would continue to allow a python function to be passed? Or maybe {"function": ...}.

Dict(choose_schema=when_key_is("type", {"foo": {...}, "bar": {...}})

Internal Schema representation

At the very least, the schema should be parsed into a Python objects with guaranteed fields & whatnot, instead of just dealing with big old bags of k/v. The schema should be parsed validated & transformed with a schema!

Could potentially even compile a schema down to efficient "instructions" to apply to a value.

Python interface

Dict(fields(
  a=String(),
  b=Integer(),
))

or maybe like

Schema(
    Dict(),
    fields(a=String(), b=Integer()),
    registry(coolschema=...),
)

lol?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions