Closed pivotaljohn closed 2 years ago
Should the #@assert/validate
annotation work on data values contained in a data values file?
#@ load("@ytt:assert", "assert")
@data/values
---
#@assert/validate ("a non-empty string", lambda v: assert.fail("length = {}", len(v)) if len(v) > 0 else None)
username: "andrew"
Should the #@assert/validate annotation work on data values contained in a data values file?
Insightful question. And I think you intuition is right: that an @assert/validate
should mean the same thing everywhere (just like an @overlay/match
does).
This points to a need to be able to declare the need for an @assert/validate
(specifically in a document containing schema).
Folding this into the overall proposal.
🙌🏻
Split this story into two:
@assert/validate
annotation (and required plumbing)@assert/validate
annotations, given a schema declaring validations.Closing since follow up PR was merged.
Given a Data Values document (and only a Data Values document), annotated with a validation rule:
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:Scenario: Valid Data Value
Given the final Data Value's value satisfies the rule: Then no error message is displayed.
Note: validations are checked after all overlays have been applied.
Notes: