I allow a user to specify a MySQL calculated field in a web form field that might read something like:
(bldgFuelCostElectricity * assetMotorSize) * if(bldgField1>bldgField2,bldgField1-bldgField2,0) * 24
At run time I will substitute other table columns for the camelcase parameters, but before I let the user save this expression as part of a report template, I would like to test the function for validity using Math.js but it doesn't like the IF() construct. Math.js does allow function name overrides, but I cannot make it work with the particular case of IF because that's a reserved word.
How can I test that a MySQL function is valid using Math.js when MySQL has certain functions that already have JavaScript equivalents?