From 46e3e25887f09b359a6f0268d9d137ba28c75c95 Mon Sep 17 00:00:00 2001 From: Tim Arney Date: Fri, 17 Jan 2025 07:26:34 -0500 Subject: [PATCH] remove server validation for required fields --- .../(form filler)/id/[...props]/actions.ts | 2 +- lib/validation/validation.tsx | 25 +------------------ 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/app/(gcforms)/[locale]/(form filler)/id/[...props]/actions.ts b/app/(gcforms)/[locale]/(form filler)/id/[...props]/actions.ts index 55314b1c2d..13c9468b87 100644 --- a/app/(gcforms)/[locale]/(form filler)/id/[...props]/actions.ts +++ b/app/(gcforms)/[locale]/(form filler)/id/[...props]/actions.ts @@ -25,7 +25,7 @@ export async function submitForm( throw new Error(`Could not find any form associated to identifier ${formId}`); } - const validateResponsesResult = await validateResponses(values, template, language); + const validateResponsesResult = await validateResponses(values, template); if (Object.keys(validateResponsesResult).length !== 0) { logMessage.warn( diff --git a/lib/validation/validation.tsx b/lib/validation/validation.tsx index 2d71b73152..2468ca120a 100644 --- a/lib/validation/validation.tsx +++ b/lib/validation/validation.tsx @@ -19,7 +19,6 @@ import { inGroup } from "@lib/formContext"; import { isFileExtensionValid, isAllFilesSizeValid } from "./fileValidationClientSide"; import { DateObject } from "@clientComponents/forms/FormattedDate/types"; import { isValidDate } from "@clientComponents/forms/FormattedDate/utils"; -import { serverTranslation } from "@i18n"; /** * getRegexByType [private] defines a mapping between the types of fields that need to be validated @@ -286,14 +285,8 @@ const valueMatchesType = (value: unknown, type: string, formElement: FormElement /** * Server-side validation the form responses */ -export const validateResponses = async ( - values: Responses, - formRecord: PublicFormRecord, - language: string -) => { +export const validateResponses = async (values: Responses, formRecord: PublicFormRecord) => { const errors: Responses = {}; - const { t } = await serverTranslation(["common"], { lang: language }); - for (const item in values) { const formElement = formRecord.form.elements.find((element) => element.id == parseInt(item)); @@ -308,22 +301,6 @@ export const validateResponses = async ( if (!result) { errors[item] = "invalid-response-data-type"; } - - // Check for required fields - if (formElement.properties.validation) { - const result = isFieldResponseValid( - values[item], - values, - formElement.type, - formElement, - formElement.properties.validation, - t - ); - - if (result) { - errors[item] = result; - } - } } return errors;