report
The
report
function is part of Conform's future export. These APIs are experimental and may change in minor versions. Learn more
A utility function that creates a SubmissionResult
object from a submission to add validation results and intended values with options to strip files and hide sensitive fields.
import { report } from '@conform-to/react/future';
const result = report(submission, options);
#Parameters
submission: Submission
The form submission object created by parseSubmission(formData)
. Contains parsed form data with structured payload, field names, and submission intent.
options.error?: Partial<FormError> | null
Error information to include in the result. Can contain:
formErrors?: string[]
- Form-level error messagesfieldErrors?: Record<string, string[]>
- Field-specific error messages
Set to null
to indicate validation passed with no errors.
options.intendedValue?: Record<string, unknown> | null
The intended form values to track what the form should contain vs. what was actually submitted.
options.keepFiles?: boolean
Controls whether file objects are preserved in the submission payload:
false
(default) - Files are stripped from the payload since they cannot be used to initialize file inputstrue
- Files are preserved
options.hideFields?: string[]
Array of field names to hide from the result by setting them to undefined
in both the submission payload and intended value. Primarily used for sensitive data like passwords that should not be sent back to the client.
report(submission, {
hideFields: ['password', 'confirmPassword'],
});
options.reset?: boolean
When true
, indicates the form should be reset to its initial state.
#Returns
A SubmissionResult
object containing:
submission: Submission
The processed submission object. May have modified payload if some fields were hidden or files are stripped.
intendedValue?: Record<string, unknown> | null
The intended form values, if different from the submission payload.
error?: FormError | null
Validation result, if any was provided in the options.
#Example
Basic error reporting
1// Report validation errors
2const result = report(submission, {
3 error: {
4 fieldErrors: {
5 email: ['Email is required'],
6 password: ['Password must be at least 8 characters'],
7 },
8 },
9});
Resetting form after successful submission
1// Reset form after successful submission
2const result = report(submission, {
3 reset: true,
4});
Hiding sensitive fields
1// Hide password fields from being sent back to client
2const result = report(submission, {
3 hideFields: ['password', 'confirmPassword'],
4 error: validationErrors,
5});