Add yaml.is_valid builtin - #150
Merged
sspaink merged 2 commits intoJul 28, 2026
Merged
Conversation
Signed-off-by: Aayush Tiwari <aayushtiwari1001@gmail.com>
Aayush10016
force-pushed
the
issue-144-yaml-is-valid
branch
from
July 12, 2026 12:28
970e376 to
3d243f6
Compare
Member
|
@Aayush10016 did you mean to open this as a draft? |
Aayush10016
marked this pull request as ready for review
July 17, 2026 15:04
Contributor
Author
|
It was initially opened as a draft while validation and DCO were being finalized. It is now marked ready for review, and the current checks are passing. Thanks for checking. |
sspaink
requested changes
Jul 28, 2026
sspaink
left a comment
Member
There was a problem hiding this comment.
Thank you for working on this!
| name = "result", | ||
| description = "`true` if `x` is valid YAML, `false` otherwise")) | ||
| public RegoBoolean yamlIsValid(EvaluationContext ctx, RegoValue[] args) { | ||
| String yamlInput = getArg(args, 0, RegoString.class).getValue(); |
Member
There was a problem hiding this comment.
OPA returns false for non-string operands rather that raising a type error. Can you catch that here and return false instead? Adding a test to cover this would also be nice.
if (!(args[0] instanceof RegoString yamlInput)) {
return RegoBoolean.FALSE;
}
Contributor
Author
There was a problem hiding this comment.
Thanks for the review. I pushed an update that:
- returns
falsefromyaml.is_validwhen the operand is not aRegoString - adds a non-string input test
- updates the JUnit/JUnit Platform versions in
opa-builtins-jsonto6.1.2
Validation passed locally:
:opa-builtins:opa-builtins-json:test --tests io.github.open_policy_agent.opa.ast.builtin.impls.JsonBuiltinsTest:opa-builtins:opa-builtins-json:test
DCO is passing now as well.
Comment on lines
+22
to
+23
| testImplementation("org.junit.jupiter:junit-jupiter:6.1.1") | ||
| testRuntimeOnly("org.junit.platform:junit-platform-launcher:6.1.1") |
Member
There was a problem hiding this comment.
Suggested change
| testImplementation("org.junit.jupiter:junit-jupiter:6.1.1") | |
| testRuntimeOnly("org.junit.platform:junit-platform-launcher:6.1.1") | |
| testImplementation("org.junit.jupiter:junit-jupiter:6.1.2") | |
| testRuntimeOnly("org.junit.platform:junit-platform-launcher:6.1.2") |
the rest of the repo is on 6.1.2
Signed-off-by: Aayush Tiwari <aayushtiwari1001@gmail.com>
Aayush10016
force-pushed
the
issue-144-yaml-is-valid
branch
from
July 28, 2026 18:07
be0abde to
0fbaa79
Compare
sspaink
approved these changes
Jul 28, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
yaml.is_validbuiltin toopa-builtins-jsonCloses #144.
Verification
JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 .\gradlew.bat --no-daemon --console=plain :opa-builtins:opa-builtins-json:testJAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 .\gradlew.bat --no-daemon --console=plain :opa-builtins:opa-builtins-json:checkNote: On this Windows environment, the first Gradle run without explicit UTF-8 failed while compiling existing Unicode box-drawing characters in
MetricsPrinter.javausing Windows-1252. Rerunning with UTF-8 completed successfully.