For the complete documentation index, see llms.txt. This page is also available as Markdown.

is_number

Tests whether a value can be cast to a number, without casting it. The guard that pairs with integer and decimal.

{% if row.qty | is_number %}...{% endif %}

Syntax

{{ value | is_number }}
Parameter
Description

value

Any value to test

Return Value

Returns true when integer/decimal would succeed on the value, false otherwise.

Examples

Report bad rows instead of importing them silently:

{% for row in rows %}
  {% unless row.price | is_number %}
    {% assign invalid = invalid | push: row.sku %}
    {% continue %}
  {% endunless %}
  {% assign price = row.price | decimal %}
{% endfor %}
{% if invalid.size > 0 %}
  {% log "Rows skipped, price is not numeric: " | append: invalid | join: ", " %}
{% endif %}

Branch on the shape of an incoming value:

Notes

  • Uses exactly the same rule as integer and decimal, so a true result guarantees the cast returns a number rather than the fallback

  • "0x1F", "1e3", "1,234", "", true and missing variables are all false

  • To inspect the underlying JavaScript type instead, use type

  • See also: integer, decimal, type

Last updated