Skip to content

Commit

Permalink
Properly check for validateObjectLocation in FormField (#3002)
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens authored Nov 5, 2024
1 parent 5686e9b commit e294002
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/components/FormField/FormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@ const FormField = ({
hasError('custom')

const isOptional = !options?.validators?.some((validator: any) => {
// Check if validator is a function with the name 'required'
// If so, it also isn't optional
if (validator.name === 'required') return true

return ['required', 'min'].includes(validator)
})

const FieldSetWrapper = isFieldSet ? FieldSet : Fragment

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const controls = {
},
render: QuestionFieldType.AssetSelect,
options: {
validators: [validateObjectLocation('container'), 'required'],
validators: [validateObjectLocation('container')],
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const straatverlichtingKlokken = {
},
render: QuestionFieldType.StreetlightSelect,
options: {
validators: [validateObjectLocation('lichtpunt'), 'required'],
validators: [validateObjectLocation('lichtpunt')],
},
},

Expand Down Expand Up @@ -294,7 +294,7 @@ const straatverlichtingKlokken = {
},
render: QuestionFieldType.ClockSelect,
options: {
validators: [validateObjectLocation('klok'), 'required'],
validators: [validateObjectLocation('klok')],
},
},

Expand Down

0 comments on commit e294002

Please sign in to comment.