Data shape based minimalistic modeling and validation

Open
#215 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
clojure, yaml
Domain
data, tooling

Research direction

No repository files or tests are named. Start by reading the proposed YAML examples and the linked malli schema documentation, then trace how yamlscript currently parses and validates YAML. Done would mean an agreed syntax and implementation that converts these shapes into usable malli schemas, with coverage for required, optional, repeated, bounded, and recursive fields.

Written by the indexing model from the issue text.

Description

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"]
Dominant language
Clojure
Stars
644
Forks
62
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from yaml/yamlscript

All issues in yaml/yamlscript

Similar issues

More Clojure issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.