diff --git a/src/config/field-overrides/categoryCombo.js b/src/config/field-overrides/categoryCombo.js index 0fb3aee1f..4b024efb7 100644 --- a/src/config/field-overrides/categoryCombo.js +++ b/src/config/field-overrides/categoryCombo.js @@ -3,6 +3,13 @@ import MultiSelect from '../../forms/form-fields/multi-select'; export default new Map([ ['categories', { + required: true, + validators: [{ // regular isRequired does not check for empty collection or array + validator(value, formState) { + return value && value.size > 0; + }, + message: 'categories_cannot_be_empty', + }], component: (props) => { let queryFilter; diff --git a/src/i18n/i18n_module_en.properties b/src/i18n/i18n_module_en.properties index ade74f999..2dc211e6f 100644 --- a/src/i18n/i18n_module_en.properties +++ b/src/i18n/i18n_module_en.properties @@ -2389,3 +2389,4 @@ org_unit_target=Organisation unit target ownership=Ownership validation_result=Validation result sql=SQL +categories_cannot_be_empty=Categories cannot be empty