When upgrading to Mirth 3.3, I found that the
validate(isEmptyString, fallback); //returns isEmptyString if not empty, or fallback if it is empty
had been changed. Prior to 3.3, validate()
always returned a string. Now with 3.3, it returns an object. This is problematic in the following code:
var procedure = validate("", ""); // used to return an empty string. Now returns an object.
var description = "This is the description";
var output = procedure || description;
Because procedure
is an object, it never returns falsey, therefore output = procedure
always.
I've also tried to convert procedure
to a string using a toString()
in the above logical, but it fails to convert it.
In the above code, what is the new standard for performing this type of check? Previous to 3.3, the above ||
would have worked wonderfully. Is there a way to force type to be string (as I mentioned, simply tacking on a .toString()
to the end of the .validate()
function does not force the variable to be of string type)?
You should be able to add an empty string to the object in question and rhino will convert it to a string allowing your 3rd line to work.
var procedure = validate("", "")+"";
var description = "This is the description";
var output = procedure || description