Skip to content

Conformance Examples 0.1.0 — Transforms: transform-abs

abs-negative-integer

abs of a negative integer returns its magnitude via {{ n | abs }}.

Template

{{ n | abs }}

Context

{
    "n": -5
}

Output

5

abs-positive-integer

abs of a positive integer is unchanged.

Template

{{ n | abs }}

Context

{
    "n": 5
}

Output

5

abs-negative-decimal

abs of a negative decimal keeps its fractional part.

Template

{{ n | abs }}

Context

{
    "n": -1.5
}

Output

1.5

abs-numeric-string

A numeric string input is parsed before taking the absolute value.

Template

{{ n | abs }}

Context

{
    "n": "-3"
}

Output

3

abs-non-numeric-input-is-null

A non-numeric input is a soft failure, so abs yields null.

Template

{{ n | abs }}

Context

{
    "n": "foo"
}

Output

null

abs-missing-input-is-null

A missing input resolves to null, so abs yields null.

Template

{{ missing | abs }}

Context

{}

Output

null

Source fixture: transforms/transform-abs.json