Schema Validation v2
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 167
- PR merge metrics
- No merged PRs in 30d
Description
_(this is the next feature increment of #561)_
---
**As a** Configuration Author
**I want to** declare what constitutes a _valid_ Data Value right in my schema definition
**In a way that** requires even less custom Starlark code from me ⭐
**And** I can write fewer annotations ⭐ because `ytt` can confidently infer for what _have_ written.
*So that**
- I can state those invariants in one central place and know they will be respected throughout the execution
- those who use my `ytt` library and violate one of those variants will receive a helpful error message
- and my overall maintenance effort/costs are less than before. ⭐
_(⭐ = a desired improvement on top of the MVP.)_
[[proposal]](https://github.com/vmware-tanzu/carvel/pull/331/files?short_path=a81faf6#diff-a81faf6d33e82e22eee1083ee484a23eda8a928b046116a2cb516e58086984b8)
[[getting started]](https://carvel.dev/blog/ytt-validations-preview/)
---
### Backlog
- _⚠️ This track of work is still being elaborated; some scope is likely missing.⚠️_
- loads of ideas for improvements can be mined from #707's [synthesis](https://miro.com/app/board/uXjVOgHIamo=/)
UX:
- [ ] Use custom violation messages
- on `@assert/validate`, implement 3-tuple rules where the third tuple is the violation template; to `@schema/validation`, add 3-tuple tules.
- note: this is critical to improve the DX around unit testing (detailed in [a conversation on #741](https://github.com/vmware-tanzu/carvel-ytt/pull/741#discussion_r969654801))
- [ ] disallow `@schema/validation` in non-schema documents.
- [ ] disallow `@assert/validate` in schema documents.
Fast Follow: other must-have OOTB rules
- [ ] `matches=`
Programmatic Validation of YAML
- [ ] Validate a YAML document that contains `@assert/validate` annotations
- expose `assert.is_valid()` as a method in `@ytt:assert` module
Include Validations in Schema Inspect
- [ ] Include validations when exporting schema to OpenAPI v3 (subset: one-for-ones)
- need: https://kubernetes.slack.com/archives/CH8KCCKA5/p1661186311752459?thread_ts=1661185491.294779&cid=CH8KCCKA5
- [ ] Include validations when exporting schema to OpenAPI v3 (subset: needing translation)
Authoring Conveniences:
- [ ] Set a default validation for descendent Data Values (`@schema/validate-string-default`)
- [ ] Infer `@schema/nullable` for all children implicated in a `@schema/validation one_not_null=`
---
### Resources
- [Schema proposal: Part 7 — Validating Documents](https://hackmd.io/pODV3wzbT56MbQTxbQOOKQ#Part-7-Validating-Documents)
- [Schema Validation proposal](https://github.com/vmware-tanzu/carvel/pull/331/files?short_path=a81faf6#diff-a81faf6d33e82e22eee1083ee484a23eda8a928b046116a2cb516e58086984b8)
- Previous Epic: #561
### Related Issues:
- #103 — originating issue
- #556 — requesting "required" use-case, explicitly.
Contributor guide
Research direction
Start with the Schema Validation proposal, the getting-started article, and the linked synthesis from #707. Review the backlog and related issues #103 and #556 to determine which increment has agreed scope. Done criteria are not defined here because the track is still being elaborated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100