10-20-2022 11:38 PM
Hi there,
Can someone explain to me why the following expression generates true as a result:
I have the following pipeline:
In JSON Generator I have:
{
"field": null
}
AutoPrep config:
Data type is set to a number; if null, 0 (zero) will be the result value.
Mapper:
Shouldn’t this validate as false? The field is a number and has the value 0.
The result after validation:
10-24-2022 09:52 AM
Hi ionutbarna,
The SnapLogic Expression’s ==
works the same as ==
in a JavaScript,
For the expression 0 == ""
, the left operand is a Number and the right is a String.
In this case, the right operand is coerced to the type Number: 0 == Number("")
.
This results in 0 == 0
and thus true.
Here is the output from the same expression in JavaScript console: