### File

`src/chain-of-responsibility/validator-factory/validator-factory-handler.ts`

### Index

###### Methods
Public append Public handle

### Methods

Public append
`append(handler: ValidatorFactoryHandler)`
Defined in src/chain-of-responsibility/validator-factory/validator-factory-handler.ts:10
Parameters :
Name | Type | Optional | Description
handler | `ValidatorFactoryHandler` |  |
Returns : `ValidatorFactoryHandler`

Public handle
`handle(validation: Validation)`
Defined in src/chain-of-responsibility/validator-factory/validator-factory-handler.ts:20
Parameters :
Name | Type | Optional | Description
validation | `Validation` |  |
Returns : `ValidatorFn`

    import { ValidatorFn } from '@angular/forms';

    import { Validation } from '../../validation';
    import { ValidationTypeNotFoundError } from './error';

    export abstract class ValidatorFactoryHandler {

      private nextHandler: ValidatorFactoryHandler;

      public append(handler: ValidatorFactoryHandler): ValidatorFactoryHandler {
        if (this.nextHandler) {
          this.nextHandler.append(handler);
        } else {
          this.nextHandler = handler;
        }

        return this;
      }

      public handle(validation: Validation): ValidatorFn {
        if (this.nextHandler) {
          return this.nextHandler.handle(validation);
        }

        throw new ValidationTypeNotFoundError(`Validation Type (${validation.type}) not found.`);
      }
    }

# results matching ""

# No results matching ""