diff --git a/lib/core/form/components/form-base.component.ts b/lib/core/form/components/form-base.component.ts index 88d355932c..76b87d761c 100644 --- a/lib/core/form/components/form-base.component.ts +++ b/lib/core/form/components/form-base.component.ts @@ -70,7 +70,7 @@ export abstract class FormBaseComponent { /** Contains a list of form field validator instances. */ @Input() - fieldValidators: FormFieldValidator[] = []; + fieldValidators: FormFieldValidator[]; /** Emitted when the supplied form values have a validation error. */ @Output() diff --git a/lib/core/form/components/widgets/date/date.widget.spec.ts b/lib/core/form/components/widgets/date/date.widget.spec.ts index 9ea6977d58..9603c06613 100644 --- a/lib/core/form/components/widgets/date/date.widget.spec.ts +++ b/lib/core/form/components/widgets/date/date.widget.spec.ts @@ -189,5 +189,20 @@ describe('DateWidgetComponent', () => { dateButton = element.querySelector('button'); expect(dateButton.disabled).toBeTruthy(); })); + + it('should set isValid to false when the value is not a correct date value', async(() => { + widget.field = new FormFieldModel(new FormModel(), { + id: 'date-field-id', + name: 'date-name', + value: 'aa', + type: 'date', + readOnly: 'false' + }); + widget.field.isVisible = true; + widget.field.readOnly = false; + fixture.detectChanges(); + + expect(widget.field.isValid).toBeFalsy(); + })); }); }); diff --git a/lib/core/form/components/widgets/date/date.widget.ts b/lib/core/form/components/widgets/date/date.widget.ts index e9f3a75fe9..ba0b3bb779 100644 --- a/lib/core/form/components/widgets/date/date.widget.ts +++ b/lib/core/form/components/widgets/date/date.widget.ts @@ -80,5 +80,4 @@ export class DateWidgetComponent extends WidgetComponent implements OnInit { } this.onFieldChanged(this.field); } - } diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts index 7c0b07abc2..c23224f19e 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts @@ -29,7 +29,9 @@ import { FormBaseComponent, WidgetVisibilityService, FormService, NotificationService, - FormRenderingService } from '@alfresco/adf-core'; + FormRenderingService, + FORM_FIELD_VALIDATORS, + FormFieldValidator } from '@alfresco/adf-core'; import { FormCloudService } from '../services/form-cloud.service'; import { FormCloud } from '../models/form-cloud.model'; import { TaskVariableCloud } from '../models/task-variable-cloud.model'; @@ -62,6 +64,9 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, @Input() data: TaskVariableCloud[]; + @Input() + fieldValidators: FormFieldValidator[] = [...FORM_FIELD_VALIDATORS]; + /** Emitted when the form is submitted with the `Save` or custom outcomes. */ @Output() formSaved: EventEmitter = new EventEmitter();