Function.validateParameters Function

Validates the parameters to a method are as expected.

var a = objVar.validateParameters(parameters,expectedParameters,validateParameterCount);

Arguments

  • parameters
    Array of parameter values passed to the method.

  • expectedParameters
    Array of JSON objects describing the expected parameters.

  • validateParameterCount
    true if extra parameters are prohibited, false if they should be ignored. The default is true.

Return Value

True if the parameters are validated, otherwise null.

Example

The following example shows how to use the validateParameters function.

Array.insert = function Array$insert(array, index, item) {
    var e = Function. validateParameters(arguments, [
        {name: "array", type: Array, elementMayBeNull: true},
        {name: "index", mayBeNull: true},
        {name: "item", mayBeNull: true}
    ]);
    if (e) throw e;
    ...
}

See Also

Other Resources

Language Reference