title: Mule 4 : What is the safest way to check and apply conditions based on data type of payload in Mule 4?
body: <p>Scenario :
  I have a payload as below :</p>
  <pre><code>{
      &quot;message&quot;: &quot;Hello world!&quot;
  }
  </code></pre>
  <p>Objective : Need to check the datatype of &quot;message&quot; field and apply a if else condition on it.</p>
  <p>Some of the methods is tried is as Follows
  Type 1 :</p>
  <pre><code>payload.message is String
  </code></pre>
  <p>Type 2:</p>
  <pre><code>typeOf(payload.message) ~= &quot;String&quot;
  </code></pre>
  <p>Type 3:</p>
  <pre><code>(typeOf(payload.message) as String) == &quot;String&quot;
  </code></pre>
  <p>Out of these which is the most reliable ways to check and apply the if else condition based on data type of a payload?</p>
  <p>Note:
  Type 2 coerces the left hand side value to match and check if its equal to right hand side so I am sure that is not a good idea. Any thoughts on 1 and 3 please?</p>