mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2501] Checkbox form Widget - TASK "Complete" button not grayed out when widget set as required. (#3161)
* Validation missing for the boolean type. * Added test cases for the recent changes
This commit is contained in:
committed by
Maurizio Vitale
parent
4293bbba83
commit
2b8f12fa57
@@ -172,6 +172,29 @@ describe('FormFieldValidator', () => {
|
||||
expect(validator.validate(field)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should succeed for check box', () => {
|
||||
let field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.BOOLEAN,
|
||||
required: true,
|
||||
value: true,
|
||||
options: [{ id: 'two', name: 'two' }]
|
||||
});
|
||||
|
||||
expect(validator.validate(field)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should fail for check box', () => {
|
||||
let field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.BOOLEAN,
|
||||
required: true,
|
||||
value: false,
|
||||
options: [{ id: 'two', name: 'two' }]
|
||||
});
|
||||
field.value = false;
|
||||
|
||||
expect(validator.validate(field)).toBeFalsy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('NumberFieldValidator', () => {
|
||||
|
@@ -34,6 +34,7 @@ export class RequiredFieldValidator implements FormFieldValidator {
|
||||
FormFieldTypes.TEXT,
|
||||
FormFieldTypes.MULTILINE_TEXT,
|
||||
FormFieldTypes.NUMBER,
|
||||
FormFieldTypes.BOOLEAN,
|
||||
FormFieldTypes.TYPEAHEAD,
|
||||
FormFieldTypes.DROPDOWN,
|
||||
FormFieldTypes.PEOPLE,
|
||||
@@ -76,6 +77,10 @@ export class RequiredFieldValidator implements FormFieldValidator {
|
||||
return field.value && field.value instanceof Array && field.value.length > 0;
|
||||
}
|
||||
|
||||
if (field.type === FormFieldTypes.BOOLEAN) {
|
||||
return field.value ? true : false;
|
||||
}
|
||||
|
||||
if (field.value === null || field.value === undefined || field.value === '') {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user