1 | import { Construct } from './construct-compat';
|
2 | export declare type Mapper = (x: any) => any;
|
3 | export declare const stringToCloudFormation: Mapper;
|
4 | export declare const booleanToCloudFormation: Mapper;
|
5 | export declare const objectToCloudFormation: Mapper;
|
6 | export declare const numberToCloudFormation: Mapper;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export declare function dateToCloudFormation(x?: Date): any;
|
15 |
|
16 |
|
17 |
|
18 | export declare function cfnTagToCloudFormation(x: any): any;
|
19 | export declare function listMapper(elementMapper: Mapper): Mapper;
|
20 | export declare function hashMapper(elementMapper: Mapper): Mapper;
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | export declare function unionMapper(validators: Validator[], mappers: Mapper[]): Mapper;
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | export declare class ValidationResult {
|
36 | readonly errorMessage: string;
|
37 | readonly results: ValidationResults;
|
38 | constructor(errorMessage?: string, results?: ValidationResults);
|
39 | get isSuccess(): boolean;
|
40 | /**
|
41 | * Turn a failed validation into an exception
|
42 | */
|
43 | assertSuccess(): void;
|
44 | /**
|
45 | * Return a string rendering of the tree of validation failures
|
46 | */
|
47 | errorTree(): string;
|
48 | /**
|
49 | * Wrap this result with an error message, if it concerns an error
|
50 | */
|
51 | prefix(message: string): ValidationResult;
|
52 | }
|
53 | /**
|
54 | * A collection of validation results
|
55 | */
|
56 | export declare class ValidationResults {
|
57 | results: ValidationResult[];
|
58 | constructor(results?: ValidationResult[]);
|
59 | collect(result: ValidationResult): void;
|
60 | get isSuccess(): boolean;
|
61 | errorTreeList(): string;
|
62 | /**
|
63 | * Wrap up all validation results into a single tree node
|
64 | *
|
65 | * If there are failures in the collection, add a message, otherwise
|
66 | * return a success.
|
67 | */
|
68 | wrap(message: string): ValidationResult;
|
69 | }
|
70 | export declare const VALIDATION_SUCCESS: ValidationResult;
|
71 | export declare type Validator = (x: any) => ValidationResult;
|
72 | /**
|
73 | * Return whether this object can be validated at all
|
74 | *
|
75 | * True unless it's undefined or a CloudFormation intrinsic
|
76 | */
|
77 | export declare function canInspect(x: any): boolean;
|
78 | export declare function validateString(x: any): ValidationResult;
|
79 | export declare function validateNumber(x: any): ValidationResult;
|
80 | export declare function validateBoolean(x: any): ValidationResult;
|
81 | export declare function validateDate(x: any): ValidationResult;
|
82 | export declare function validateObject(x: any): ValidationResult;
|
83 | export declare function validateCfnTag(x: any): ValidationResult;
|
84 | /**
|
85 | * Return a list validator based on the given element validator
|
86 | */
|
87 | export declare function listValidator(elementValidator: Validator): Validator;
|
88 | /**
|
89 | * Return a hash validator based on the given element validator
|
90 | */
|
91 | export declare function hashValidator(elementValidator: Validator): Validator;
|
92 | /**
|
93 | * Decorate a validator with a message clarifying the property the failure is for.
|
94 | */
|
95 | export declare function propertyValidator(propName: string, validator: Validator): Validator;
|
96 | /**
|
97 | * Return a validator that will fail if the passed property is not present
|
98 | *
|
99 | * Does not distinguish between the property actually not being present, vs being present but 'null'
|
100 | * or 'undefined' (courtesy of JavaScript), which is generally the behavior that we want.
|
101 | *
|
102 | * Empty strings are considered "present"--don't know if this agrees with how CloudFormation looks
|
103 | * at the world.
|
104 | */
|
105 | export declare function requiredValidator(x: any): ValidationResult;
|
106 | /**
|
107 | * Require a property from a property bag.
|
108 | *
|
109 | * @param props the property bag from which a property is required.
|
110 | * @param name the name of the required property.
|
111 | * @param typeName the name of the construct type that requires the property
|
112 | *
|
113 | * @returns the value of ``props[name]``
|
114 | *
|
115 | * @throws if the property ``name`` is not present in ``props``.
|
116 | */
|
117 | export declare function requireProperty(props: {
|
118 | [name: string]: any;
|
119 | }, name: string, context: Construct): any;
|
120 | /**
|
121 | * Validates if any of the given validators matches
|
122 | *
|
123 | * We add either/or words to the front of the error mesages so that they read
|
124 | * more nicely. Example:
|
125 | *
|
126 | * Properties not correct for 'FunctionProps'
|
127 | * codeUri: not one of the possible types
|
128 | * either: properties not correct for 'S3LocationProperty'
|
129 | * bucket: required but missing
|
130 | * key: required but missing
|
131 | * version: required but missing
|
132 | * or: '3' should be a 'string'
|
133 | *
|
134 | */
|
135 | export declare function unionValidator(...validators: Validator[]): Validator;
|