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 flag | Type | Description |
|---|---|---|
endsWith | string | The 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
| Scenario | Message |
|---|---|
| Value does not end with the suffix | Must end with ".csv" (the message names your suffix) |
Examples
| Value | Rule | Result |
|---|---|---|
'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,
fileExtensionis often a cleaner fit — it checks the extension list rather than the raw string.