testFor()

Creates functions for testing values.

This function is valid in v2.23.0. This function has been downloaded 2 times.

Parameter

{…Array} ruleX
An array containing (1) the path, (2) optionally the comparator as a string and (3) the value to check the variable at that path against. Each part of the path should be a separate item in the array. For example ["details", "age", ">=", 18] can be used to make sure that object.details.age >= 18 occurs (object would be passed to the function returned by testFor()). If no comparator is supplied === will be used. If one of the paths doesn't exist the entire test will fail.

Returns

{Function}
A function which can be used to test any value according to the given rule(s). If all of the rules pass for the value passed into the returned function then the returned function will return true, otherwise it will return false.

Required Function

This function directly requires the following function which is included automatically:

Requiring Functions

This function is directly required by the following functions:

  • everyWhere()
    Determines whether a specific test passes for all of the items in an array.
  • findWhere()
    Finds the first item in an array which matches the specified criteria.
  • testForNot()
    Creates functions for testing values.