From 6b6335d0760d849e35abc4701bdc62927088b5ac Mon Sep 17 00:00:00 2001 From: Pierre Huyghe Date: Tue, 11 Jan 2022 13:36:10 +0100 Subject: [PATCH] fix(libs/form-builder): use the right field rules (#32) --- libs/form-builder/src/lib/formBuilder.tsx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/libs/form-builder/src/lib/formBuilder.tsx b/libs/form-builder/src/lib/formBuilder.tsx index 4ed2aa7..a6cebf9 100644 --- a/libs/form-builder/src/lib/formBuilder.tsx +++ b/libs/form-builder/src/lib/formBuilder.tsx @@ -23,7 +23,7 @@ import { handleFormBuilderError } from './utils/handleFormBuilderError.util'; import { Stepper } from './components/stepper.component'; import { FormField } from './components/formField.component'; import { SubmitField } from './components/submitField.component'; -import { getFieldRules } from './utils/validation.utils'; +import { getFieldRules, FieldRules } from './utils/validation.utils'; import { PreviousStepField } from './components/previousStepField.component'; import { FORM_CLASSNAMES } from './constants'; @@ -62,7 +62,6 @@ export function FormBuilder({ getValues, setValue, trigger, - watch, setFocus } = useForm({ mode: behavior, @@ -95,7 +94,7 @@ export function FormBuilder({ [fieldId]: getFieldRules({ validation, extraValidation }) }; }, - {} + {} as { [key: string]: FieldRules } ), [extraValidation, fields, fieldsById] ); @@ -144,18 +143,13 @@ export function FormBuilder({ const { type, id, defaultValue, meta, validation } = fields[fieldId]; - const validationRules = getFieldRules({ - validation, - extraValidation - }); - return ( (