Skip to content

Conformance Examples 0.1.0 — Transforms: transform-has

has-property-value-true

With two arguments, returns true when some struct's property equals the value.

Template

{{ items | has: "k" "b" }}

Context

{
    "items": [
        {
            "k": "a"
        },
        {
            "k": "b"
        }
    ]
}

Output

true

has-property-value-false

With two arguments, returns false when no struct's property equals the value.

Template

{{ items | has: "k" "z" }}

Context

{
    "items": [
        {
            "k": "a"
        },
        {
            "k": "b"
        }
    ]
}

Output

false

has-property-truthy

With one argument, returns true when some struct's property is truthy.

Template

{{ items | has: "ok" }}

Context

{
    "items": [
        {
            "ok": false
        },
        {
            "ok": true
        }
    ]
}

Output

true

has-non-list-is-null

has operates only on lists; a string input yields null.

Template

{{ x | has: "k" }}

Context

{
    "x": "hi"
}

Output

null

has-non-struct-contents-is-null

has expects a list of structs; non-struct contents yield null.

Template

{{ xs | has: "k" }}

Context

{
    "xs": [
        1
    ]
}

Output

null

Source fixture: transforms/transform-has.json