1 | /** @module validate */
|
2 | import { IValidationRule } from './IValidationRule';
|
3 | import { Schema } from './Schema';
|
4 | import { ValidationResult } from './ValidationResult';
|
5 | /**
|
6 | * Validation rule negate another rule.
|
7 | * When embedded rule returns no errors, than this rule return an error.
|
8 | * When embedded rule return errors, than the rule returns no errors.
|
9 | *
|
10 | * @see [[IValidationRule]]
|
11 | *
|
12 | * ### Example ###
|
13 | *
|
14 | * let schema = new Schema()
|
15 | * .withRule(new NotRule(
|
16 | * new ValueComparisonRule("EQ", 1)
|
17 | * ));
|
18 | *
|
19 | * schema.validate(1); // Result: error
|
20 | * schema.validate(5); // Result: no error
|
21 | */
|
22 | export declare class NotRule implements IValidationRule {
|
23 | private readonly _rule;
|
24 | /**
|
25 | * Creates a new validation rule and sets its values
|
26 | *
|
27 | * @param rule a rule to be negated.
|
28 | */
|
29 | constructor(rule: IValidationRule);
|
30 | /**
|
31 | * Validates a given value against this rule.
|
32 | *
|
33 | * @param path a dot notation path to the value.
|
34 | * @param schema a schema this rule is called from
|
35 | * @param value a value to be validated.
|
36 | * @param results a list with validation results to add new results.
|
37 | */
|
38 | validate(path: string, schema: Schema, value: any, results: ValidationResult[]): void;
|
39 | }
|