mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2764] Applied new doc tool features to core library (#3383)
This commit is contained in:
committed by
Eugenio Romano
parent
5831bc1d77
commit
41777e0540
@@ -2,9 +2,10 @@
|
||||
Added: v2.0.0
|
||||
Status: Active
|
||||
---
|
||||
|
||||
# FormFieldValidator interface
|
||||
|
||||
Defines how the input fields of Form and Task Details components are validated.
|
||||
Defines how the input fields of [`Form`](../../lib/process-services/task-list/models/form.model.ts) and Task Details components are validated.
|
||||
|
||||
## Basic Usage
|
||||
|
||||
@@ -52,26 +53,26 @@ Perform validation on `field`.
|
||||
|
||||
You can supply a set of validator objects for a form using its `fieldValidators` property.
|
||||
ADF will determine if a validator should be used with a given field by calling its
|
||||
`isSupported` method, passing the field's FormFieldModel as a parameter. If the validator
|
||||
does support the field then its `validate` method will be called on the FormFieldModel
|
||||
`isSupported` method, passing the field's [`FormFieldModel`](../core/form-field.model.md) as a parameter. If the validator
|
||||
does support the field then its `validate` method will be called on the [`FormFieldModel`](../core/form-field.model.md)
|
||||
during the validation phase.
|
||||
|
||||
Several validator classes are predefined for you to use:
|
||||
|
||||
| Validator name | Checks that: |
|
||||
| -------------- | ------------ |
|
||||
| `RequiredFieldValidator` | Field is not left blank |
|
||||
| `NumberFieldValidator` | Field contains numeric data |
|
||||
| `MinLengthFieldValidator` | Field text has at least a minimum number of characters |
|
||||
| `MaxLengthFieldValidator` | Field text has no more than a maximum number of characters |
|
||||
| `MinValueFieldValidator` | Numeric field's value is greater than a lower limit |
|
||||
| `MaxValueFieldValidator` | Numeric field's vaue is less than an upper limit |
|
||||
| `RegExFieldValidator` | Field text matches a regular expression |
|
||||
| `DateFieldValidator` | Field contains a date in the correct format |
|
||||
| `MinDateFieldValidator` | Date within a field occurs after a certain starting point |
|
||||
| `MaxDateFieldValidator` | Date within a field occurs before a certain end point |
|
||||
| [`RequiredFieldValidator`](../../lib/core/form/components/widgets/core/form-field-validator.ts) | Field is not left blank |
|
||||
| [`NumberFieldValidator`](../../lib/core/form/components/widgets/core/form-field-validator.ts) | Field contains numeric data |
|
||||
| [`MinLengthFieldValidator`](../../lib/core/form/components/widgets/core/form-field-validator.ts) | Field text has at least a minimum number of characters |
|
||||
| [`MaxLengthFieldValidator`](../../lib/core/form/components/widgets/core/form-field-validator.ts) | Field text has no more than a maximum number of characters |
|
||||
| [`MinValueFieldValidator`](../../lib/core/form/components/widgets/core/form-field-validator.ts) | Numeric field's value is greater than a lower limit |
|
||||
| [`MaxValueFieldValidator`](../../lib/core/form/components/widgets/core/form-field-validator.ts) | Numeric field's vaue is less than an upper limit |
|
||||
| [`RegExFieldValidator`](../../lib/core/form/components/widgets/core/form-field-validator.ts) | Field text matches a regular expression |
|
||||
| [`DateFieldValidator`](../../lib/core/form/components/widgets/core/form-field-validator.ts) | Field contains a date in the correct format |
|
||||
| [`MinDateFieldValidator`](../../lib/core/form/components/widgets/core/form-field-validator.ts) | Date within a field occurs after a certain starting point |
|
||||
| [`MaxDateFieldValidator`](../../lib/core/form/components/widgets/core/form-field-validator.ts) | Date within a field occurs before a certain end point |
|
||||
|
||||
The `FORM_FIELD_VALIDATORS` array contains an instance of each of these classes. You can assign this to the `fieldValidators` property of an Activiti Form or Activiti Task Details component to enable standard validation.
|
||||
The `FORM_FIELD_VALIDATORS` array contains an instance of each of these classes. You can assign this to the `fieldValidators` property of an Activiti [`Form`](../../lib/process-services/task-list/models/form.model.ts) or Activiti [Task Details component](../process-services/task-details.component.md) to enable standard validation.
|
||||
|
||||
### Custom validators
|
||||
|
||||
@@ -79,9 +80,9 @@ You can implement your own custom validator classes if the standard set doesn't
|
||||
features you need. For example, you could check for consistency between separate fields on
|
||||
the form (currency values adding up to a given total, say).
|
||||
|
||||
The `type` property of `FormFieldModel` is often used in the `isSupported` function, since
|
||||
The `type` property of [`FormFieldModel`](../core/form-field.model.md) is often used in the `isSupported` function, since
|
||||
validation methods typically apply only to specific types of data.
|
||||
The [FormFieldTypes](https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-activiti-form/src/components/widgets/core/form-field-types.ts)
|
||||
The [`FormFieldTypes`](../../lib/core/form/components/widgets/core/form-field-types.ts)
|
||||
class defines convenient constants for the type strings.
|
||||
|
||||
The validator in the example
|
||||
@@ -126,7 +127,7 @@ export class AppComponent {
|
||||
}
|
||||
```
|
||||
|
||||
You can now use the 'fieldValidators' property of the Form or Task Details components to assign your
|
||||
You can now use the 'fieldValidators' property of the [`Form`](../../lib/process-services/task-list/models/form.model.ts) or Task Details components to assign your
|
||||
custom validator set:
|
||||
|
||||
```html
|
||||
|
Reference in New Issue
Block a user