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

Latest commit

 

History

History
23 lines (16 loc) · 390 Bytes

regex.md

File metadata and controls

23 lines (16 loc) · 390 Bytes

Regex

Evaluates a regex on the input and validates if matches.

Valid values:

validator.regex(/[a-z]/).validate('a');
validator.regex(/[0-9]/).validate(0);

Invalid values:

validator.regex(/[a-z]/).validate(0);
validator.regex(/[0-9]/).validate('a');

Throw error if the regex is invalid:

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