Formify Docs

Includes

Require a value to contain a specific substring.

Includes

Validates that a value contains a given substring anywhere within it.

Configuration

Config flagTypeDescription
includesstringThe 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

ScenarioMessage
Substring not foundMust include "@" (the message names your substring)

Examples

ValueRuleResult
'user@site.com'includes: '@'✅ Valid
'usersite.com'includes: '@'❌ Invalid

Notes

  • The check is case-sensitive: 'HELLO' fails includes: 'hello'.
  • Position is not restricted — the substring may appear at the start, middle, or end.

On this page