remix-params-helper
remix-params-helper copied to clipboard
Is there a way to pass FormData that's already consumed?
Is there a way to pass FormData that's already consumed?
I realize I could just use straight Zod at that point but I really like the API of this project. Instead of passing my Request
object, it'd be cool to do
const formData = await request.formData();
// Pull some value that helps me decide which validation schema to use
const employeeType = formData.get('employeeType');
const result = await getFormData(formData, getValidationSchema(employeeType));
if (!result.success) {
return json(result.errors, { status: 400 });
}
I didn't know if there was a technical reason that the entire request object needed to be passed. As we know the body cannot be consumed twice so there's no potential for getting data from it to assist in making validation decisions.
Thoughts?