Question

what is the best funtion to validate that the given string is an integer
What is the best method to validate that the given string is an integer
-
Like (0)
-

The best method is to associate the field in which the string is being typed with a property rule whose type is declared to be "integer" and then make sure validation is allowed on that field. /Eric

Nice , Let me add a constraint it is a string variable then what would be the best function?

There is a isInteger function in String library for this purpose.

It is 10 digit number so is integer fails, as it accept integer only upto a certain range

is there any library function similar to regex?

Hi Rasaiya,
There is an OOTB function:pxGetRegex in V62 but is blocked in the system right now. Here is the code used for this function and is being used in a blocked activity:Data-SecurityVAUtility.createJssearchPage Check, if this info helps you.
Java Code:
return "(?:((?>\\b\\w+\\b))(?:(?:(?>\\s)*\\+?=)|\\.append\\()(?![^;]*\\b(?:parseLong|parseInt|createPage|findPage|crossScriptingFilter))[^\\n\\r]*(?:getParamValue|getActiveValue|getSaveValue|getActive\\(\\)\\.getStringValue)(?![^;]*(?:equals|length|intValue|longValue|booleanValue|startsWith|endsWith))[^;]*;(?=(?>.|\\n|\\r)*(<%=\\s*(\\1)\\s*%>|appendString\\([^()]*(?:\\([^()]*\\)[^()]*)*\\b(?:\\1)\\b)))|(?:(?:<%=|appendString\\()(?![^;]*\\b(?:parseLong|parseInt|createPage|findPage|crossScriptingFilter))[^\\n\\r;%]*(?:getParamValue|getActiveValue|getSaveValue|getActive\\(\\)\\.getStringValue)(?![^;]*(?:equals|length|intValue|longValue|booleanValue|startsWith|endsWith)).*)";
Hi Rasaiya,
There is an OOTB function:pxGetRegex in V62 but is blocked in the system right now. Here is the code used for this function and is being used in a blocked activity:Data-SecurityVAUtility.createJssearchPage Check, if this info helps you.
Java Code:
return "(?:((?>\\b\\w+\\b))(?:(?:(?>\\s)*\\+?=)|\\.append\\()(?![^;]*\\b(?:parseLong|parseInt|createPage|findPage|crossScriptingFilter))[^\\n\\r]*(?:getParamValue|getActiveValue|getSaveValue|getActive\\(\\)\\.getStringValue)(?![^;]*(?:equals|length|intValue|longValue|booleanValue|startsWith|endsWith))[^;]*;(?=(?>.|\\n|\\r)*(<%=\\s*(\\1)\\s*%>|appendString\\([^()]*(?:\\([^()]*\\)[^()]*)*\\b(?:\\1)\\b)))|(?:(?:<%=|appendString\\()(?![^;]*\\b(?:parseLong|parseInt|createPage|findPage|crossScriptingFilter))[^\\n\\r;%]*(?:getParamValue|getActiveValue|getSaveValue|getActive\\(\\)\\.getStringValue)(?![^;]*(?:equals|length|intValue|longValue|booleanValue|startsWith|endsWith)).*)";
Thanks,
Ravi Kumar.

Check out the below logic and let us know if this works.
@pxContainsViaRegex(.IntegerProp, "[-+]?\\d+(\\.\\d+)?", false)
This pattern takes into account any "." or even +-

Will try and share the result âº