Regex schema
A function which creates a parsing rule to ensure that a given value is a regex.
Arguments
- (Optional): A list of modifiers
custom
: Learn more.
- (Optional): A custom object with error messages to be displayed when validation fails or there are type errors.
Example
import { regex } from '@nordic-ui/validathor';
const regexRule = regex('Value must be a regex');
try {
const parsedValue = regexRule.parse(/(on|off)/i);
console.log('Parsed value:', parsedValue);
} catch (error) {
console.error('Parsing failed:', error.message);
}