Formify Docs

No Whitespace

Reject values that contain any whitespace characters.

No Whitespace

Validates that a value contains no whitespace at all — not just leading/trailing whitespace, but also spaces, tabs, and line breaks anywhere in the string.

Configuration

Config flagTypeDescription
noWhitespacebooleanWhen true, rejects any whitespace character in the value.

With useForm

const form = useForm({
  initialValues: { apiKey: '' },
  validationSchema: {
    apiKey: { noWhitespace: true },
  },
});

With the V builder

import { V } from 'formify-js';

V.noWhitespace();

Default message

ScenarioMessage
Any whitespace foundMust not contain whitespace

Examples

ValueResult
'abc123'✅ Valid
'abc 123'❌ Invalid (internal space)
' abc'❌ Invalid (leading space)
'abc\t'❌ Invalid (tab)

Notes

  • Stricter than the trim option: trim only removes edges, while noWhitespace forbids whitespace everywhere.
  • Ideal for API keys, tokens, usernames, and other machine-generated identifiers.

On this page