Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Latest commit

 

History

History
27 lines (20 loc) · 583 Bytes

type-of.md

File metadata and controls

27 lines (20 loc) · 583 Bytes

Type Of

Evaluates a regex on the type of input and validates if matches.

Valid values:

validator.typeOf(/boolean/).validate(true);
validator.typeOf(/number/).validate(1);
validator.typeOf(/object/).validate({});
validator.typeOf(/string/).validate('foo');

Invalid values:

validator.typeOf(/boolean/).validate('foo');
validator.typeOf(/number/).validate({});
validator.typeOf(/object/).validate(1);
validator.typeOf(/string/).validate(true);

Throw error if the regex is invalid:

validator.typeOf({}).validate('foo'); // Error('Invalid RegExp.')