Formify Docs

Trimmed

Reject values with leading or trailing whitespace.

Trimmed

Validates that a value has no leading or trailing whitespace. Internal spaces are allowed — only the edges are checked.

Configuration

Config flagTypeDescription
trimmedbooleanWhen true, rejects values that start or end with whitespace.

With useForm

const form = useForm({
  initialValues: { name: '' },
  validationSchema: {
    name: { trimmed: true },
  },
});

With the V builder

import { V } from 'formify-js';

V.trimmed();

Default message

ScenarioMessage
Leading or trailing whitespaceMust not have leading or trailing whitespace

Examples

ValueResult
'John Doe'✅ Valid
' John'❌ Invalid (leading space)
'Doe '❌ Invalid (trailing space)

Notes

  • Lighter than noWhitespace: internal spaces like the one in 'John Doe' pass.
  • Use the global trim option if you would rather silently remove edge whitespace than reject the value.

On this page