How to add check of any number of Blank space in apigee javascript

Seems trim(), replace(), match and regex.test() are not accessiable in apigee
so how we add check for blank spaces , i had one method its check for empty field with “” but i need for " " , " " .etc this kind of dyanamically spaces check

function checkEmpty(value) {
if (value === “” || value === null || value === undefined) {
return false;
} else
return true;
}
this is working for me , just wanted check for dyanamic number of blank space

The below sample code works in both Apigee X/Edge - Rhino 1.7.13 and Rhino 1.7.12 respectively. Note that I tried both .match and .test and both works fine.

function isEmptyOrSpaces(str){
  //return str === null || str.match(/^\s*$/) !== null;
  return str === null || (/^\s*$/).test(str);
}

var stringWithSpaces = '   ';

if(isEmptyOrSpaces(stringWithSpaces)){
    print("String has spaces");
}
1 Like