Formify Docs

Ends With

Require a value to end with a specific suffix.

Ends With

Validates that a value ends with a given suffix string.

Configuration

Config flagTypeDescription
endsWithstringThe required suffix.
endsWith[string, string]Tuple form — the suffix plus a custom message.

With useForm

const form = useForm({
  initialValues: { file: '' },
  validationSchema: {
    file: { endsWith: '.csv' },
  },
});

With a custom message:

file: { endsWith: ['.csv', 'Only CSV exports are allowed'] }

With the V builder

import { V } from 'formify-js';

V.endsWith('.csv');

Default message

ScenarioMessage
Value does not end with the suffixMust end with ".csv" (the message names your suffix)

Examples

ValueRuleResult
'report.csv'endsWith: '.csv'✅ Valid
'report.xlsx'endsWith: '.csv'❌ Invalid

Notes

  • The check is case-sensitive: 'report.CSV' fails when the suffix is '.csv'.
  • For file uploads, fileExtension is often a cleaner fit — it checks the extension list rather than the raw string.

On this page