title: How to validate if a string property is numeric on a Logic Apps Liquid template?
body: <p>I'm creating a Liquid template, and I need to validate whether a string property in my JSON payload is numeric (contains only digits). </p>
  
  <p>I've tried to implement the tip suggested <a href="https://ecommerce.shopify.com/c/ecommerce-design/t/how-to-check-if-a-string-is-just-a-number-not-the-same-as-checking-if-the-var-is-a-int-or-a-string-solution-here-474153" rel="nofollow noreferrer">here</a> </p>
  
  <pre><code>{% assign test = "A string" | plus: 0 %}
  {{ test }}
  {% assign test_d = "123456" | plus: 0 %}
  {{ test_d }}
  </code></pre>
  
  <blockquote>
    <p>{{ test }} will print 1 while {{ test_d }} will print 123456. 
    So you could do a check:</p>
  </blockquote>
  
  <pre><code>{% if test_d != 0 %}
      {{ "I'm a Int!"}}
  {% else %}
      {{ "I'm a String!"}}
  {% endif %}
  </code></pre>
  
  <p>and <a href="https://stackoverflow.com/questions/27198710/convert-string-to-integer-in-shopify-liquid">here</a>. </p>
  
  <blockquote>
    <p>When using assign, either of these options should give you a number:</p>
  </blockquote>
  
  <pre><code>{% assign var1 = var1 | plus: 0 %}
  {% assign var2 = var2 | times: 1 %}
  </code></pre>
  
  <p>However, they don't seem to work the same in the <a href="http://dotliquidmarkup.org/" rel="nofollow noreferrer">DotLiquid</a> implementation. </p>
  
  <p>This is a template I've created using those tips. </p>
  
  <pre><code>{
    {% assign numValue1 = content.myDoc.myProperty | Plus: 0 %}
    {% assign numValue2 = content.myDoc.myProperty | Times: 1 %}
    {% assign numValue3 = content.myDoc.myProperty | Times: 2 %}
  
    {% if numValue1 != 0 %}
      "validation1": true,
    {% else %}
      "validation1": false,
    {% endif %}
  
    "numValue1": "{{numValue1}}",
    "numValue2": "{{numValue2}}",
    "numValue3": "{{numValue3}}"
  
  }
  </code></pre>
  
  <p>However, the filter <code>Plus: 0</code> concatenates the char '0' to the string, instead of behaving as described for the Ruby implementation. And <code>Times</code> repeats the string, instead of returning a number as suggested. </p>
  
  <p>This is the output when my property is <code>12345</code></p>
  
  <pre><code>{
      "validation1": true,
      "numValue1": "123450",
      "numValue2": "12345",
      "numValue3": "1234512345"
  } 
  </code></pre>
  
  <p>And this is the output when my property is <code>ABC123</code></p>
  
  <pre><code>{
      "validation1": true,
      "numValue1": "ABC1230",
      "numValue2": "ABC123",
      "numValue3": "ABC123ABC123"
  }
  </code></pre>
  
  <p>I know that the DotLiquid implementation is not exactly the same as the Ruby one. I've checked the source code of DotLiquid, and those filters are coded as they are behaving in my tests. </p>
  
  <p>Any suggestions? </p>