-
-
Notifications
You must be signed in to change notification settings - Fork 1
3.4. Validators
Ettiene Mare edited this page Mar 11, 2020
·
11 revisions
The validators will check the validity of the components.
The validator will return a boolean value, true for valid and false for invalid.
The validator service will use the validators to validate the controls.
The validator should be registered in the validator service.
export class ValidatorService {
private validators: Array<Validator> = [
new RequiredValidator("required")
];
}
The validators should inherit from the Validator class.
export abstract class Validator {
constructor(public name: string) { }
abstract validate(context: Context, control: Control, config: any): boolean;
setError(control: Control, error: boolean, message?: string) {
control.error = error;
control.errorMessage = error ? message : null;
if(control.el) {
control.el.setAttribute("error", control.error ? "true" : "false");
control.el.setAttribute("errorMessage", control.errorMessage);
}
if(control.el.nextSibling["attributes"]["wf-error"])
control.el.nextSibling.textContent = control.errorMessage;
}
}
Validator | Description |
---|---|
3.4.1. Required | This validator will test if the control has a value. |
3.4.2. Regex | This validator will validate the control value against a regular expression. |
3.4.3. Range | This validator will test if the control value falls in a range. |
3.4.4. Custom | A custom validator will test if the control value is valid. |
-
3.1.Introduction
3.2. Core
3.3. Services
3.3.1. Workflow
3.3.2. Analytics
3.3.3. Config
3.3.4. Model
3.3.5. Validator
3.3.6. Http3.4. Validators
3.5. Pipes
3.5.1. Currency
3.6. Activities
3.6.1. Page
3.6.2. Api
3.6.3. Assign
3.6.4. Decision
3.6.5. Code
3.6.6. IPC
3.6.7. Finish
3.6.8. Redirect
3.6.9. Switch
3.6.10. Custom3.7. Web Components
3.7.1. React