[AAE-6209] Remove default dropdown value (#7331)

This commit is contained in:
Dharan
2021-10-29 16:50:32 +05:30
committed by GitHub
parent b3140b626c
commit c596a06eda
2 changed files with 13 additions and 1 deletions

View File

@@ -101,6 +101,18 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBe(false);
});
it('should fail for dropdown with null value', () => {
const field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.DROPDOWN,
value: null,
required: true,
options: [{ id: 'one', name: 'one' }],
selectionType: 'multiple'
});
expect(validator.validate(field)).toBe(false);
});
it('should fail for radio buttons', () => {
const field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.RADIO_BUTTONS,

View File

@@ -60,7 +60,7 @@ export class RequiredFieldValidator implements FormFieldValidator {
if (field.type === FormFieldTypes.DROPDOWN) {
if (field.hasMultipleValues) {
return !!field.value.length;
return Array.isArray(field.value) && !!field.value.length;
}
if (field.hasEmptyValue && field.emptyOption) {