[AAE-30863] updated validators to set proper button state (#10667)

This commit is contained in:
tomasz hanaj
2025-02-25 09:30:14 +01:00
committed by GitHub
parent 1e83be9194
commit 0c725a1c90
14 changed files with 102 additions and 106 deletions

View File

@@ -252,13 +252,29 @@ There are two other functions that can be very useful when you need to control f
### Field Validators
You can supply a set of validator objects to the form using the `fieldValidators`
property. Each validator implements a check for a particular type of data (eg, a
date validator might check that the date in the field falls between 1980 and 2017).
You can supply a set of validator objects to the form using the `fieldValidators` property. To do this you must use Token `FORM_CLOUD_FIELD_VALIDATORS_TOKEN`. This is a A DI token that allows to inject additional form field validators. Each validator implements a check for a particular type of data (eg, a date validator might check that the date in the field falls between 1980 and 2017).
ADF supplies a standard set of validators that handle most common cases but you can
also implement your own custom validators to replace or extend the set. See the
[Form Field Validator](../../core/interfaces/form-field-validator.interface.md) interface for full details and examples.
```ts
import { NgModule } from '@angular/core';
import { FORM_SERVICE_FIELD_VALIDATORS_TOKEN } from '@alfresco/adf-core';
@NgModule({
imports: [
...Import Required Modules
],
providers: [
{
provide: FORM_SERVICE_FIELD_VALIDATORS_TOKEN,
useValue: [new AdditionalFormFieldValidator()]
}
]
})
export class ExampleModule {}
```
### Common scenarios
#### Rendering a form using form definition JSON

View File

@@ -15,7 +15,6 @@ Based on property taskDetails: TaskDetailsCloudModel shows a form or a screen.
<adf-cloud-user-task
[appName]="appName"
[displayModeConfigurations]="displayConfigurations"
[fieldValidators]="formFieldValidators"
[showTitle]="false"
[showValidationIcon]="false"
[taskId]="taskId"
@@ -38,7 +37,6 @@ Based on property taskDetails: TaskDetailsCloudModel shows a form or a screen.
|---------------------------|---------------------------------------|---------------|---------------------------------------------------|
| appName | `string` | "" | App id to fetch corresponding form and values. |
| readOnly | `boolean` | false | Toggle readonly state of the task. |
| fieldValidators | `FormFieldValidator[]` | | Allows to provide additional validators to the form field. |
| showCancelButton | `boolean` | true | Toggle rendering of the `Cancel` button. |
| showCompleteButton | `boolean` | true | Toggle rendering of the `Complete` button. |
| showTitle | `boolean` | true | Toggle rendering of the form title. |