Skip to content

Commit a4e8908

Browse files
committed
builtins: update json.is_valid and yaml.is_valid for OPA v0.44.0
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
1 parent a675159 commit a4e8908

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
node-version: [14.x, 16.x, 18.x]
3232
opa-version:
3333
- 0.30.2 # last version with ABI 1.1, 0.31.0+ has ABI 1.2
34-
- 0.41.0 # 0.35.0 is the first release with https://github.com/open-policy-agent/opa/pull/4055
34+
- 0.45.0 # 0.35.0 is the first release with https://github.com/open-policy-agent/opa/pull/4055
3535

3636
steps:
3737
- uses: actions/checkout@v3

src/builtins/json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function isValidJSON(str) {
22
if (typeof str !== "string") {
3-
return;
3+
return false;
44
}
55
try {
66
JSON.parse(str);

src/builtins/yaml.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ function parse(str) {
3030
}
3131

3232
module.exports = {
33-
// is_valid is expected to return nothing if input is invalid otherwise
34-
// true/false for it being valid YAML.
35-
"yaml.is_valid": (str) => typeof str === "string" ? parse(str).ok : undefined,
33+
// is_valid is expected to return false if input is invalid; and true/false for it being valid YAML.
34+
"yaml.is_valid": (str) => typeof str === "string" && parse(str).ok,
3635
"yaml.marshal": (data) => yaml.stringify(data),
3736
"yaml.unmarshal": (str) => parse(str).result,
3837
};

0 commit comments

Comments
 (0)