<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Null Check Validation Failing</title><link>https://community.appian.com/discussions/f/general/21247/null-check-validation-failing</link><description>We are having a requirement where we are getting values from an external application via a webAPI. In the web API we are casting the data into a CDT. The value we receive from the application would be something like. { &amp;quot;person&amp;quot; : {&amp;quot;name&amp;quot;: &amp;quot;Shaun&amp;quot;,&amp;quot;age</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Null Check Validation Failing</title><link>https://community.appian.com/thread/82841?ContentTypeID=1</link><pubDate>Tue, 22 Jun 2021 08:00:09 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d26038ab-b814-4600-9469-a58b773d26eb</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;This is a very common problem. In your case, length returns 1 because there is a single item, the NULL, in there.&lt;/p&gt;
&lt;p&gt;In general I suggest to do all the data validation in the web API before initiating the process. If some of the fields are mandatory, then check for the individual fields.&lt;/p&gt;
&lt;p&gt;To check whether a variable contains &amp;quot;something&amp;quot; I created an expression over the years. It covers 23 cases of &amp;quot;that variable is empty&amp;quot;.&lt;/p&gt;
&lt;p&gt;The rule input must be of type &amp;quot;any&amp;quot;!&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if(
  isnull(ri!value),
  true,
  a!localVariables(
    local!typeNum: runtimetypeof(ri!value),
    
    /* Strings */
    if(
      local!typeNum = &amp;#39;type!{http://www.appian.com/ae/types/2009}Text&amp;#39;,
      /* Ignore white space */
      len(trim(ri!value)) = 0,
      
    /* List of Variant */
    if(
      local!typeNum = &amp;#39;type!{http://www.appian.com/ae/types/2009}Variant?list&amp;#39;,
      all(fn!isnull, a!flatten(ri!value)),
      
    /* Lists */
    if(
      /* Try to take first item in list and cast it to a list of itself */
      /* then compare its datatype to the incoming data type */
      local!typeNum = runtimetypeof(cast(runtimetypeof({index(ri!value, 1, null)}), ri!value)),
      
      /* Flatten takes care of lists in lists in lists in ... */
      /* List has zero non-null items, length() already ignores null values*/
      length(a!flatten(ri!value)) = 0,

    /* DataSubsets */
    if(
      local!typeNum = &amp;#39;type!{http://www.appian.com/ae/types/2009}DataSubset&amp;#39;,
      if(
        ri!value.totalCount &amp;lt; 0, /* This is necessary in case fetchTotalCount=false */
        if(
          isnull(ri!value.data),
          true,
          length(ri!value.data) = 0
        ),
        ri!value.totalCount = 0
      ),

      /* No idea what this could be so it is considered to not be null */
      false
    ))))
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>