Skip to content

Commit

Permalink
fix: Crash when editing column with only one defined min/max value
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayur committed Dec 7, 2024
1 parent c1cd3e6 commit 20b69da
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions apps/web/design-system/validation/MinMaxValidation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,33 @@ export function MinMaxValidation({
control={control}
name={`validations.${index}.min`}
rules={{
validate: (value, formValues) => validateMinMax(value, (formValues.validations?.[index] as any).max),
validate: (value, formValues) => validateMinMax(value, (formValues.validations?.[index] as any)?.max),
}}
render={({ field }) => (
<NumberInput
size={size}
min={min}
placeholder={minPlaceholder}
error={(errors?.validations?.[index] as any)?.min?.message}
value={field.value}
onChange={(value) => (value === '' ? field.onChange(undefined) : field.onChange(value))}
value={field.value ? field.value : undefined}
onChange={(value) => field.onChange(value === '' ? undefined : value)}
/>
)}
/>
<Controller
control={control}
name={`validations.${index}.max`}
rules={{
validate: (value, formValues) => validateMinMax((formValues.validations?.[index] as any).min, value),
validate: (value, formValues) => validateMinMax((formValues.validations?.[index] as any)?.min, value),
}}
render={({ field }) => (
<NumberInput
size={size}
max={max}
placeholder={maxPlaceholder}
error={(errors?.validations?.[index] as any)?.max?.message}
value={field.value}
onChange={(value) => (value === '' ? field.onChange(undefined) : field.onChange(value))}
value={field.value ? field.value : undefined}
onChange={(value) => field.onChange(value === '' ? undefined : value)}
/>
)}
/>
Expand Down

0 comments on commit 20b69da

Please sign in to comment.