Skip to content

Commit

Permalink
Corrected validation now that select fields are comboboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Lessard committed Apr 16, 2024
1 parent 2cb00f2 commit e739a63
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions contenthub/hydration/hydration-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function formIsComplete(metadataSchema, formValues) {
const incomplete = metadataSchema.find((schema) => {
if(!schema.required) return;
if(schema.requires) return;
return Array.isArray(formValues[schema.mapToProperty]) ? formValues[schema.mapToProperty].length === 0 : formValues[schema.mapToProperty] === '';
return !(schema.mapToProperty in formValues) || Array.isArray(formValues[schema.mapToProperty]) ? formValues[schema.mapToProperty].length === 0 : formValues[schema.mapToProperty] === '';
});

if(incomplete) return false;
Expand Down Expand Up @@ -197,15 +197,12 @@ export function getMetadataSchema(facetOptions){
placeholder: 'Select one',
element: 'text',
getSuggestions: async (value) => {
return [
{id: '', name: 'N/A'},
...facetOptions['gmo-campaignName'].filter(
(option) => {
const name = option.name.toLowerCase();
return value.toLowerCase().split(' ').every((val) => name.includes(val));
}
)
]
return facetOptions['gmo-campaignName'].filter(
(option) => {
const name = option.name.toLowerCase();
return value.toLowerCase().split(' ').every((val) => name.includes(val));
}
)
},
},
{
Expand Down

0 comments on commit e739a63

Please sign in to comment.