mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-10643] Form validation for dropdown required field (#7844)
This commit is contained in:
@@ -113,6 +113,18 @@ describe('FormFieldValidator', () => {
|
|||||||
expect(validator.validate(field)).toBe(false);
|
expect(validator.validate(field)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should fail for dropdown with empty object', () => {
|
||||||
|
const field = new FormFieldModel(new FormModel(), {
|
||||||
|
type: FormFieldTypes.DROPDOWN,
|
||||||
|
value: {},
|
||||||
|
required: true,
|
||||||
|
options: [{ id: 'one', name: 'one' }],
|
||||||
|
selectionType: 'multiple'
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(validator.validate(field)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it('should fail for radio buttons', () => {
|
it('should fail for radio buttons', () => {
|
||||||
const field = new FormFieldModel(new FormModel(), {
|
const field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.RADIO_BUTTONS,
|
type: FormFieldTypes.RADIO_BUTTONS,
|
||||||
|
@@ -69,6 +69,10 @@ export class RequiredFieldValidator implements FormFieldValidator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (field.required && typeof field.value === 'object' && field.value && !Object.keys(field.value).length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.type === FormFieldTypes.RADIO_BUTTONS) {
|
if (field.type === FormFieldTypes.RADIO_BUTTONS) {
|
||||||
|
Reference in New Issue
Block a user