UNPKG

847 BTypeScriptView Raw
1/** @module validate */
2import { Schema } from './Schema';
3import { ValidationResult } from './ValidationResult';
4/**
5 * Interface for validation rules.
6 *
7 * Validation rule can validate one or multiple values
8 * against complex rules like: value is in range,
9 * one property is less than another property,
10 * enforce enumerated values and more.
11 *
12 * This interface allows to implement custom rules.
13 */
14export interface IValidationRule {
15 /**
16 * Validates a given value against this rule.
17 *
18 * @param path a dot notation path to the value.
19 * @param schema a schema this rule is called from
20 * @param value a value to be validated.
21 * @param results a list with validation results to add new results.
22 */
23 validate(path: string, schema: Schema, value: any, results: ValidationResult[]): void;
24}