UNPKG

1.33 kBTypeScriptView Raw
1/** @module validate */
2import { IValidationRule } from './IValidationRule';
3import { Schema } from './Schema';
4import { ValidationResult } from './ValidationResult';
5/**
6 * Validation rule to check that value is excluded from the list of constants.
7 *
8 * @see [[IValidationRule]]
9 *
10 * ### Example ###
11 *
12 * let schema = new Schema()
13 * .withRule(new ExcludedRule(1, 2, 3));
14 *
15 * schema.validate(2); // Result: 2 must not be one of 1, 2, 3
16 * schema.validate(10); // Result: no errors
17 */
18export declare class ExcludedRule implements IValidationRule {
19 private readonly _values;
20 /**
21 * Creates a new validation rule and sets its values.
22 *
23 * @param values a list of constants that value must be excluded from
24 */
25 constructor(...values: any[]);
26 /**
27 * Validates the given value. None of the values set in this ExcludedRule object must exist
28 * in the value that is given for validation to pass.
29 *
30 * @param path the dot notation path to the value that is to be validated.
31 * @param schema (not used in this implementation).
32 * @param value the value that is to be validated.
33 * @param results the results of the validation.
34 */
35 validate(path: string, schema: Schema, value: any, results: ValidationResult[]): void;
36}