Function conformsTo

  • Checks if object conforms to source by invoking the predicate properties of source with the corresponding property values of object.

    Note: This method is equivalent to conforms when source is partially applied.

    Type Parameters

    • T extends Record<string, any>

    Parameters

    • object: T

      The object to inspect.

    • source: {
          [key in string | number | symbol]?: ((value) => boolean)
      }

      The object of property predicates to conform to.

    Returns boolean

    Returns true if object conforms, else false.

    Since

    5.12.0

    Example

    const object = { 'a': 1, 'b': 2 }

    conformsTo(object, { 'b': function(n) { return n > 1 } })
    // => true

    conformsTo(object, { 'b': function(n) { return n > 2 } })
    // => false