approvejs icon indicating copy to clipboard operation
approvejs copied to clipboard

Regex test throws an error in IE 11

Open MarcoDeT opened this issue 6 years ago • 1 comments

Hi,

When using the format validation attribute in IE 11 approvejs throws the error that toString is not an object. Below you have the affected function:

/** * Returns an object containing the arguments for a test's expected parameters. */ _getArgs: function(params) { var pars = {}; // Does the test for this rule expect any paramaters? this._eachExpected(params, function(expects, expectsLength) { // Check if the rule object has the required parameter. if (params.constraint.hasOwnProperty(expects)) { // Add the expected parameter value to the pars object. pars[expects] = params.constraint[expects]; } else if (expectsLength <= 1 && (/^[A-Za-z0-9]+$/i.test(params.constraint) || toString.call(params.constraint) === '[object RegExp]')) { // Set the parameter to the rule's value. pars[expects] = params.constraint; } else { throw 'approve.value(): ' + params.rule + ' expects the ' + expects + ' parameter.'; } }); // Does the rule have config if(params.constraint.hasOwnProperty('config')) { // Add the config to the pars object. pars.config = params.constraint.config; } // Return the parameters object return pars; }

The toString call must be corrected to Object.prototype.toString.call(params.constraint) because IE is not that smart to look for toString in Object's prototype.

MarcoDeT avatar Jan 28 '19 22:01 MarcoDeT

Thanks for letting me know @MarcoDeT .

I will get on fixing the issue.

CharlGottschalk avatar Feb 11 '19 08:02 CharlGottschalk