Includes
Require a value to contain a specific substring.
Includes
Validates that a value contains a given substring anywhere within it.
Configuration
| Config flag | Type | Description |
|---|---|---|
includes | string | The required substring. |
includes | [string, string] | Tuple form — the substring plus a custom message. |
With useForm
const form = useForm({
initialValues: { referral: '' },
validationSchema: {
referral: { includes: '@' },
},
});With a custom message:
referral: { includes: ['@', 'The value must contain an @'] }With the V builder
import { V } from 'formify-js';
V.includes('@');Default message
| Scenario | Message |
|---|---|
| Substring not found | Must include "@" (the message names your substring) |
Examples
| Value | Rule | Result |
|---|---|---|
'user@site.com' | includes: '@' | ✅ Valid |
'usersite.com' | includes: '@' | ❌ Invalid |
Notes
- The check is case-sensitive:
'HELLO'failsincludes: 'hello'. - Position is not restricted — the substring may appear at the start, middle, or end.