Return validation errors
A server action needs to return field-level validation messages after parsing submitted form data.
Conform · Function
Creates a SubmissionResult from a parsed submission, optionally attaching validation errors and controlling returned values. It can reset the form, strip files, or hide sensitive fields.
report turns a parsed submission and optional result settings into a SubmissionResult. It can attach validation errors, provide a target form value, reset the form, remove file objects, and hide selected fields from the returned submission and target value.
report(submission, options)| Name | Type | Description |
|---|---|---|
submission | Submission | The parsed submission to process. |
options | ReportOptions | Optional settings controlling errors, target value, reset behavior, file preservation, and hidden fields. |
A SubmissionResult containing the processed submission and any configured target value, error, or reset state.
report packages a submission together with validation information and optional file-stripping or field-hiding behavior.error option.targetValue when the client should apply a different form value than the submitted payload.hideFields removes selected fields from both returned value representations by replacing them with undefined.reset when the client should restore the form to its initial state.import { report } from '@conform-to/react/future';
const result = report(submission, {
error: {
fieldErrors: {
email: ['Email is required'],
password: ['Password must be at least 8 characters'],
},
},
});Creates a submission result containing field-level validation errors.
A server action needs to return field-level validation messages after parsing submitted form data.
A server action must apply a transformed or empty value instead of the submitted payload.
A successful mutation should tell the client to restore the initial form state.
A response must avoid returning uploaded files or confidential fields.
report return?report accepts a parsed submission and optional settings, then returns a SubmissionResult. The result can include the processed submission, validation error information, a target value, and a reset flag.
Follow-up: How would you return schema errors? Pass the schema result's error payload through the error option; for schema validation, the default error shape is string[].
Set error to an object containing formErrors and/or fieldErrors. Field errors map field names to error payloads, allowing the client to associate messages with individual controls.
Follow-up: How can you report only a form-level error? Supply error: { formErrors: ... } without field-level entries.
The hideFields option accepts field names and sets those fields to undefined in both the submission payload and target value. This is useful when the response must not expose sensitive data.
Follow-up: What other value transformations are supported? File preservation can be controlled separately, and targetValue can specify the value to apply or be set to null for an empty value.
SubmissionResultSubmissionparseSubmissionresolveSubmission