---
cases:
  - note: jsonbuiltins/json is_valid
    query: data.generated.p = x
    modules:
      - |
        package generated

        documents := [
        	`plainstring`,
        	`{`,
        	`{"json": "ok"}`,
        ]

        p := [x | doc = documents[_]; json.is_valid(doc, x)]
    want_result:
      - x:
          - false
          - false
          - true
    strict_error: true
  - note: jsonbuiltins/json is_valid not string
    query: data.generated.p = x
    modules:
      - |
        package generated

        p := x if {
        	json.is_valid(input.foo, x)
        }
    input:
      foo: 1
    want_result:
      - x: false
    strict_error: true
  - note: jsonbuiltins/yaml is_valid
    query: data.generated.p = x
    modules:
      - |
        package generated

        documents := [
        	`foo:
           - qux: bar
           - baz: 2`,
        	`foo:
           - qux: bar
           - baz: {`,
        	`{"json": "ok"}`,
        ]

        p := [x | doc = documents[_]; yaml.is_valid(doc, x)]
    want_result:
      - x:
          - true
          - false
          - true
    strict_error: true
  - note: jsonbuiltins/yaml is_valid not string
    query: data.generated.p = x
    modules:
      - |
        package generated

        p := x if {
        	yaml.is_valid(input.foo, x)
        }
    input:
      foo: 1
    want_result:
      - x: false
    strict_error: true
