regex
Validates that the value matches a regular expression.
Usage
vue
<VfText name="code" label="Code" rules="regex:/^[A-Z]{3}-\d{4}$/" />vue
<template>
<VfText name="code" label="Code" rules="regex:/^[A-Z]{3}-\d{4}$/" />
</template>ts
{
code: {
type: 'text',
label: 'Code',
rules: 'regex:/^[A-Z]{3}-\\d{4}$/',
},
}Parameters
| Parameter | Description |
|---|---|
pattern | The regular expression in /pattern/flags form. |
Behavior
A pattern= prefix is also supported and is optional:
vue
<VfText name="code" rules="regex:pattern=/^[A-Z]{3}-\d{4}$/" />The rule fails closed: when the pattern is missing or malformed, no value passes, and a warning is logged in development.
Error Messages
| Key | Default Message |
|---|---|
rule_regex_error | The {attribute} format is invalid. |