Skip to content

Commit

Permalink
fix(libs/form-builder): use the right field rules (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpierre74 authored Jan 11, 2022
1 parent 0c09ada commit 6b6335d
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions libs/form-builder/src/lib/formBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -62,7 +62,6 @@ export function FormBuilder({
getValues,
setValue,
trigger,
watch,
setFocus
} = useForm<FieldValues>({
mode: behavior,
Expand Down Expand Up @@ -95,7 +94,7 @@ export function FormBuilder({
[fieldId]: getFieldRules({ validation, extraValidation })
};
},
{}
{} as { [key: string]: FieldRules }
),
[extraValidation, fields, fieldsById]
);
Expand Down Expand Up @@ -144,18 +143,13 @@ export function FormBuilder({
const { type, id, defaultValue, meta, validation } =
fields[fieldId];

const validationRules = getFieldRules({
validation,
extraValidation
});

return (
<Controller
key={id}
name={id}
control={control}
defaultValue={defaultValue}
rules={validationRules}
rules={validationRulesById[fieldId]}
render={({ field }) => (
<FormField
id={id}
Expand Down

0 comments on commit 6b6335d

Please sign in to comment.