Skip to main content

instanceof

$instanceof

Validates that the input is an instance of the specified constructor.

Parameters

  • clazz (Function, required): The constructor function to test against.

Example

// Validate that a value is an instance of a custom class
new Schema('any').validator({$instanceof: MyClass})

// Validate that a value is a Map
new Schema('any').validator({$instanceof: Map})

// Validate that a value is an Error
new Schema('any').validator({$instanceof: Error})