Skip to content

Latest commit

 

History

History
53 lines (30 loc) · 1.49 KB

API.md

File metadata and controls

53 lines (30 loc) · 1.49 KB

Table of Contents

coerce

Validate an object is an instance of the expected type, or is a valid constructor object for the requested type

Parameters

  • value any The value for validation

  • Type any The type for instance of comparison

  • message string The message to be displayed if coercion fails

  • Throws TypeError If the value is not coercable.

Returns any Instance of provided Type

coerceArray

Validate an array of objects are an instance of the expected type, or are a valid constructor object for the requested type

Parameters

  • values Array<any> The array of values for validation

  • Type any The type for instance of comparison

  • message string The message to be displayed if coercion fails

  • Throws TypeError If values is not an array

  • Throws TypeError One of the array values is not coercable.

Returns Array<any> Array of instances of provided Type