@decaf-ts/decorator-validation
Version:
simple decorator based validation engine
42 lines (41 loc) • 1.35 kB
TypeScript
import { ValidatorDefinition } from "../types";
import { IValidatorRegistry } from "../types";
import { Validator } from "./Validator";
/**
* @summary Base Implementation of a Validator Registry
*
* @prop {Validator[]} [validators] the initial validators to register
*
* @class ValidatorRegistry
* @implements IValidatorRegistry<T>
*
* @category Validation
*/
export declare class ValidatorRegistry<T extends Validator> implements IValidatorRegistry<T> {
private cache;
private customKeyCache;
constructor(...validators: (ValidatorDefinition | Validator)[]);
/**
* @summary retrieves the custom keys
*/
getCustomKeys(): {
[indexer: string]: string;
};
/**
* @summary retrieves the registered validators keys
*/
getKeys(): string[];
/**
* @summary Retrieves a validator
*
* @param {string} validatorKey one of the {@link ValidationKeys}
* @return {Validator | undefined} the registered Validator or undefined if there is nono matching the provided key
*/
get<T extends Validator>(validatorKey: string): T | undefined;
/**
* @summary Registers the provided validators onto the registry
*
* @param {T[] | ValidatorDefinition[]} validator
*/
register<T extends Validator>(...validator: (ValidatorDefinition | T)[]): void;
}