import BaseTask from './base-task' ; import { TaskContext , TaskResultOptions } from './types/tasks' ; export type ValidationResult = { isValid : boolean ; options ? : TaskResultOptions ; } ; export default abstract class BaseValidationTask extends BaseTask { validationSteps : Map < string , ( ) => ValidationResult | Promise < ValidationResult > > ; param pluginName param context constructor ( pluginName , context ) { super ( pluginName , context ) ; this . validationSteps = new Map ( ) ; } /**
     * Adds componennt data to the rule metadata.
     */ protected addRuleComponentMetadata ( ) { this . addRule ( { properties : { component : { name : 'validation' , } , } , } ) ; } param messageText param validate protected addValidationStep ( messageText , validate ) { this . validationSteps . set ( messageText , validate ) ; } returns async validate ( ) { let results = new Map < string , ValidationResult > ( ) ; for ( let [ messageText , validate ] of this . validationSteps ) { results . set ( messageText , await validate ( ) ) ; } return results ; } param messageText param isValid param options param options . location param options . properties protected addValidationResult ( messageText , isValid , options ? ) { this . addResult ( messageText , isValid ? 'pass' : 'fail' , isValid ? 'none' : 'error' , options ) ; } }