-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow when= to access value, parent, and root nodes
Resolves #733
- Loading branch information
Showing
10 changed files
with
137 additions
and
37 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
pkg/validations/filetests/when=/can-use-parent-value.tpltest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
counters: | ||
enabled: true | ||
#@assert/validate ("fail", lambda v: fail("fails")), when=lambda par: par["enabled"] | ||
foo: "" | ||
#@assert/validate ("fail", lambda v: fail("fails")), when=lambda par: not par["enabled"] | ||
bar: "" | ||
|
||
+++ | ||
|
||
ERR: | ||
- "foo" (stdin:4) requires "fail"; fail: fails (by stdin:3) |
11 changes: 11 additions & 0 deletions
11
pkg/validations/filetests/when=/can-use-root-value.tpltest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
enabled: true | ||
counters: | ||
#@assert/validate ("fail", lambda v: fail("fails")), when=lambda root: not root[0]["enabled"] | ||
foo: "" | ||
#@assert/validate ("fail", lambda v: fail("fails")), when=lambda root, document: root[0]["enabled"] and len(root[0]["counters"]) == 2 | ||
bar: "" | ||
|
||
+++ | ||
|
||
ERR: | ||
- "bar" (stdin:6) requires "fail"; fail: fails (by stdin:5) |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
pkg/validations/filetests/when=/rejects-callable-arg-failing.tpltest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
#@ load("@ytt:assert", "assert") | ||
|
||
#@assert/validate min_len=5, when=lambda v: fail("error while checking when=") | ||
#@assert/validate min_len=5, when=lambda v: fail("error from within lambda") | ||
foo: bar | ||
|
||
+++ | ||
|
||
ERR: | ||
- fail: error while checking when= | ||
Validating "foo": Failure evaluating when=: fail: error from within lambda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ foo: bar | |
+++ | ||
|
||
ERR: | ||
- want when= to be bool, got string | ||
Validating "foo": want when= to be bool, got string |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters