Skip to content

Data shape based minimalistic modeling and validation #215

Description

@amiika

It would be cool to be able to define and validate data using yaml shapes & yamlscript. Sure one can define data using JSON schema structures and use that to validate YAML, but something more minimalistic and data-driven like malli schemas in YAML would be more concise and easier to maintain.

Something like:

foo: 
  bar: boolean # Fields mandatory by default
  baz ?: string # Optional
  qux +: number? # 1..n 
  quux *: integer? # 0..n
  quuux 0..4: pos-int? #
  foo ?: foo # Ref to self

This type of syntax could be parsed to build for example malli schema registry and utilize existing built-in schemas as much as possible:

[:schema
 {:registry {"foo" [:map
                    {:closed true}
                    [:bar :boolean]
                    [:baz {:optional true} :string]
                    [:qux [:+ number?]]
                    [:quux [:* integer?]]
                    [:quuux [:repeat {:min 0, :max 4} pos-int?]]
                    [:foo {:optional true} [:ref "foo"]]]}}
             
 "foo"]

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions