Class TValidatorContext

Unit

Declaration

type TValidatorContext = class(TInterfacedObject, IValidatorContext)

Description

Class that groups all validators, as well as establishes the validation order.

Hierarchy

Overview

Methods

Public constructor Create;
Public function Add(AValidator: IValidatorBase): IValidatorContext;
Public function HandleValidation(ACommand: ICommandBuilder): TArray<string>;
Public function Validate(ACommand: ICommandBuilder): TArray<string>;

Description

Methods

Public constructor Create;

Default class constructor just to create a basic instance of it. It does not require a call to the desctructor as it is interface-based.

Public function Add(AValidator: IValidatorBase): IValidatorContext;

Successive calls to the add method are responsible for creating the validation context. This method adds an IValidatorBase and sets it as the successor if a previous IValidatorBase exists.

Parameters
AValidator
A valid instance of IValidatorBase responsible for processing a specific type of validation.
Public function HandleValidation(ACommand: ICommandBuilder): TArray<string>;

Executes the validation of the first added IValidatorBase, being the responsibility of this object to call its successor IValidatorBase and so on.

Parameters
ACommand
CommandBuilder instance containing the arguments, commands and options configured to be validated against the arguments passed to it.
Public function Validate(ACommand: ICommandBuilder): TArray<string>;

Builds the validation context by adding each class of type IValidatorBase. It then calls the first validator triggering the validator pattern.

Parameters
ACommand
CommandBuilder instance containing the arguments, commands and options configured to be validated against the arguments passed to it.

Generated by PasDoc 0.16.0.