Test a string against a regular expression. @param regex - The regular expression to match the value with.
(regex: RegExp)
| 53 | @param regex - The regular expression to match the value with. |
| 54 | */ |
| 55 | matches(regex: RegExp): this { |
| 56 | return this.addValidator({ |
| 57 | message: (value, label) => `Expected ${label} to match \`${regex}\`, got \`${value}\``, |
| 58 | validator: value => regex.test(value), |
| 59 | }); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | Test a string to start with a specific value. |