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

Annotate Data Value Schema with validation #611

Closed
Tracked by #561
pivotaljohn opened this issue Feb 22, 2022 · 0 comments
Closed
Tracked by #561

Annotate Data Value Schema with validation #611

pivotaljohn opened this issue Feb 22, 2022 · 0 comments
Assignees

Comments

@pivotaljohn
Copy link
Contributor

pivotaljohn commented Feb 22, 2022

Given a Data Values schema, annotated with a validation rule:

#! schema.yml

#@ load("@ytt:assert", "assert")
@data/values-schema
---
#@schema/validation ("a non-empty string", lambda v: assert.fail("length = {}", len(v)) if len(v) > 0 else None)
username: ""

Details at Proposal > Specification > @schema/validation.

Scenario: Invalid Data Value

Given the final Data Value's value does not satisfies the rule:
When ytt runs
Then reports a Data Values violation error message:

$ ytt -f schema.yml --data-values-inspect
ytt: Error: One or more data values were invalid:
- "adminPort" requires a valid value: a non-empty string; length = 0 (by schema.yml:6).

Details at Proposal > Specification > @schema/validation.

Scenario: Valid Data Value

Given the final Data Value's value satisfies the rule:
Then no error message is displayed.

$ ytt -f schema.yml -v username=alice --data-values-inspect
username: alice

Notes:

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

No branches or pull requests

2 participants