v-type
Validation type of value is assignable.
Install
$ npm install --save v-type
Usage
const vType = ; ;//=> true ;//=> TypeError: Type `Array` is not assignable to type `String`
API
vType(input, TypeName, [message])
Returns throw TypeError
if input
is not assignable to type TypeName
.
input
Required: true
Type: any
TypeName
Required: true
Type: constructor<Function>
The constructor function - Function
, Object
, Array
, Map
, etc...
message
Type: string
Set the default message.
Example:
{ ; console;} ;//=> 'yo' ;//=> 'TypeError: Expected `bar` to be of type `Object`'
License
MIT © Guntur Poetra