@ng-formworks/core 16.3.0 → 17.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/esm2022/lib/framework-library/framework-library.service.mjs +174 -174
  2. package/esm2022/lib/framework-library/framework.mjs +14 -14
  3. package/esm2022/lib/framework-library/no-framework.component.mjs +17 -17
  4. package/esm2022/lib/framework-library/no-framework.module.mjs +26 -26
  5. package/esm2022/lib/framework-library/no.framework.mjs +18 -18
  6. package/esm2022/lib/json-schema-form.component.mjs +765 -765
  7. package/esm2022/lib/json-schema-form.module.mjs +25 -25
  8. package/esm2022/lib/json-schema-form.service.mjs +675 -675
  9. package/esm2022/lib/locale/de-validation-messages.mjs +59 -59
  10. package/esm2022/lib/locale/en-validation-messages.mjs +59 -59
  11. package/esm2022/lib/locale/es-validation-messages.mjs +56 -56
  12. package/esm2022/lib/locale/fr-validation-messages.mjs +59 -59
  13. package/esm2022/lib/locale/index.mjs +7 -7
  14. package/esm2022/lib/locale/it-validation-messages.mjs +59 -59
  15. package/esm2022/lib/locale/pt-validation-messages.mjs +59 -59
  16. package/esm2022/lib/locale/zh-validation-messages.mjs +59 -59
  17. package/esm2022/lib/shared/convert-schema-to-draft6.function.mjs +299 -299
  18. package/esm2022/lib/shared/form-group.functions.mjs +441 -441
  19. package/esm2022/lib/shared/format-regex.constants.mjs +53 -53
  20. package/esm2022/lib/shared/index.mjs +11 -11
  21. package/esm2022/lib/shared/json-schema.functions.mjs +783 -783
  22. package/esm2022/lib/shared/json.validators.mjs +883 -883
  23. package/esm2022/lib/shared/jsonpointer.functions.mjs +1025 -1025
  24. package/esm2022/lib/shared/layout.functions.mjs +1153 -1153
  25. package/esm2022/lib/shared/merge-schemas.function.mjs +344 -344
  26. package/esm2022/lib/shared/utility.functions.mjs +379 -379
  27. package/esm2022/lib/shared/validator.functions.mjs +583 -583
  28. package/esm2022/lib/widget-library/add-reference.component.mjs +48 -48
  29. package/esm2022/lib/widget-library/button.component.mjs +41 -41
  30. package/esm2022/lib/widget-library/checkbox.component.mjs +46 -46
  31. package/esm2022/lib/widget-library/checkboxes.component.mjs +52 -52
  32. package/esm2022/lib/widget-library/file.component.mjs +35 -35
  33. package/esm2022/lib/widget-library/hidden.component.mjs +33 -33
  34. package/esm2022/lib/widget-library/index.mjs +54 -54
  35. package/esm2022/lib/widget-library/input.component.mjs +38 -38
  36. package/esm2022/lib/widget-library/message.component.mjs +33 -33
  37. package/esm2022/lib/widget-library/none.component.mjs +20 -20
  38. package/esm2022/lib/widget-library/number.component.mjs +44 -44
  39. package/esm2022/lib/widget-library/one-of.component.mjs +35 -35
  40. package/esm2022/lib/widget-library/orderable.directive.mjs +123 -123
  41. package/esm2022/lib/widget-library/radios.component.mjs +44 -44
  42. package/esm2022/lib/widget-library/root.component.mjs +44 -44
  43. package/esm2022/lib/widget-library/section.component.mjs +78 -78
  44. package/esm2022/lib/widget-library/select-framework.component.mjs +51 -51
  45. package/esm2022/lib/widget-library/select-widget.component.mjs +46 -46
  46. package/esm2022/lib/widget-library/select.component.mjs +41 -41
  47. package/esm2022/lib/widget-library/submit.component.mjs +55 -55
  48. package/esm2022/lib/widget-library/tab.component.mjs +30 -30
  49. package/esm2022/lib/widget-library/tabs.component.mjs +53 -53
  50. package/esm2022/lib/widget-library/template.component.mjs +46 -46
  51. package/esm2022/lib/widget-library/textarea.component.mjs +37 -37
  52. package/esm2022/lib/widget-library/widget-library.module.mjs +41 -41
  53. package/esm2022/lib/widget-library/widget-library.service.mjs +225 -225
  54. package/esm2022/ng-formworks-core.mjs +4 -4
  55. package/esm2022/public_api.mjs +12 -12
  56. package/fesm2022/ng-formworks-core.mjs +9103 -9103
  57. package/fesm2022/ng-formworks-core.mjs.map +1 -1
  58. package/index.d.ts +5 -5
  59. package/lib/framework-library/framework-library.service.d.ts +55 -55
  60. package/lib/framework-library/framework.d.ts +13 -13
  61. package/lib/framework-library/no-framework.component.d.ts +8 -8
  62. package/lib/framework-library/no-framework.module.d.ts +9 -9
  63. package/lib/framework-library/no.framework.d.ts +10 -10
  64. package/lib/json-schema-form.component.d.ts +218 -218
  65. package/lib/json-schema-form.module.d.ts +11 -11
  66. package/lib/json-schema-form.service.d.ts +115 -115
  67. package/lib/locale/de-validation-messages.d.ts +1 -1
  68. package/lib/locale/en-validation-messages.d.ts +1 -1
  69. package/lib/locale/es-validation-messages.d.ts +1 -1
  70. package/lib/locale/fr-validation-messages.d.ts +1 -1
  71. package/lib/locale/index.d.ts +7 -7
  72. package/lib/locale/it-validation-messages.d.ts +1 -1
  73. package/lib/locale/pt-validation-messages.d.ts +1 -1
  74. package/lib/locale/zh-validation-messages.d.ts +1 -1
  75. package/lib/shared/convert-schema-to-draft6.function.d.ts +21 -21
  76. package/lib/shared/form-group.functions.d.ts +100 -100
  77. package/lib/shared/format-regex.constants.d.ts +19 -19
  78. package/lib/shared/index.d.ts +9 -9
  79. package/lib/shared/json-schema.functions.d.ts +193 -193
  80. package/lib/shared/json.validators.d.ts +441 -441
  81. package/lib/shared/jsonpointer.functions.d.ts +416 -416
  82. package/lib/shared/layout.functions.d.ts +83 -83
  83. package/lib/shared/merge-schemas.function.d.ts +19 -19
  84. package/lib/shared/utility.functions.d.ts +165 -165
  85. package/lib/shared/validator.functions.d.ts +364 -364
  86. package/lib/widget-library/add-reference.component.d.ts +20 -20
  87. package/lib/widget-library/button.component.d.ts +21 -21
  88. package/lib/widget-library/checkbox.component.d.ts +24 -24
  89. package/lib/widget-library/checkboxes.component.d.ts +24 -24
  90. package/lib/widget-library/file.component.d.ts +21 -21
  91. package/lib/widget-library/hidden.component.d.ts +19 -19
  92. package/lib/widget-library/index.d.ts +47 -47
  93. package/lib/widget-library/input.component.d.ts +22 -22
  94. package/lib/widget-library/message.component.d.ts +15 -15
  95. package/lib/widget-library/none.component.d.ts +8 -8
  96. package/lib/widget-library/number.component.d.ts +25 -25
  97. package/lib/widget-library/one-of.component.d.ts +21 -21
  98. package/lib/widget-library/orderable.directive.d.ts +41 -41
  99. package/lib/widget-library/radios.component.d.ts +23 -23
  100. package/lib/widget-library/root.component.d.ts +17 -17
  101. package/lib/widget-library/section.component.d.ts +19 -19
  102. package/lib/widget-library/select-framework.component.d.ts +18 -18
  103. package/lib/widget-library/select-widget.component.d.ts +18 -18
  104. package/lib/widget-library/select.component.d.ts +24 -24
  105. package/lib/widget-library/submit.component.d.ts +24 -24
  106. package/lib/widget-library/tab.component.d.ts +14 -14
  107. package/lib/widget-library/tabs.component.d.ts +20 -20
  108. package/lib/widget-library/template.component.d.ts +18 -18
  109. package/lib/widget-library/textarea.component.d.ts +21 -21
  110. package/lib/widget-library/widget-library.module.d.ts +31 -31
  111. package/lib/widget-library/widget-library.service.d.ts +22 -22
  112. package/package.json +5 -5
  113. package/public_api.d.ts +9 -9
@@ -1,364 +1,364 @@
1
- import { AbstractControl } from '@angular/forms';
2
- import { Observable } from 'rxjs';
3
- /**
4
- * Validator utility function library:
5
- *
6
- * Validator and error utilities:
7
- * _executeValidators, _executeAsyncValidators, _mergeObjects, _mergeErrors
8
- *
9
- * Individual value checking:
10
- * isDefined, hasValue, isEmpty
11
- *
12
- * Individual type checking:
13
- * isString, isNumber, isInteger, isBoolean, isFunction, isObject, isArray,
14
- * isMap, isSet, isPromise, isObservable
15
- *
16
- * Multiple type checking and fixing:
17
- * getType, isType, isPrimitive, toJavaScriptType, toSchemaType,
18
- * _toPromise, toObservable
19
- *
20
- * Utility functions:
21
- * inArray, xor
22
- *
23
- * Typescript types and interfaces:
24
- * SchemaPrimitiveType, SchemaType, JavaScriptPrimitiveType, JavaScriptType,
25
- * PrimitiveValue, PlainObject, IValidatorFn, AsyncIValidatorFn
26
- *
27
- * Note: 'IValidatorFn' is short for 'invertable validator function',
28
- * which is a validator functions that accepts an optional second
29
- * argument which, if set to TRUE, causes the validator to perform
30
- * the opposite of its original function.
31
- */
32
- export type SchemaPrimitiveType = 'string' | 'number' | 'integer' | 'boolean' | 'null';
33
- export type SchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'null' | 'object' | 'array';
34
- export type JavaScriptPrimitiveType = 'string' | 'number' | 'boolean' | 'null' | 'undefined';
35
- export type JavaScriptType = 'string' | 'number' | 'boolean' | 'null' | 'undefined' | 'object' | 'array' | 'map' | 'set' | 'arguments' | 'date' | 'error' | 'function' | 'json' | 'math' | 'regexp';
36
- export type PrimitiveValue = string | number | boolean | null | undefined;
37
- export interface PlainObject {
38
- [k: string]: any;
39
- }
40
- export type IValidatorFn = (c: AbstractControl, i?: boolean) => PlainObject;
41
- export type AsyncIValidatorFn = (c: AbstractControl, i?: boolean) => any;
42
- /**
43
- * '_executeValidators' utility function
44
- *
45
- * Validates a control against an array of validators, and returns
46
- * an array of the same length containing a combination of error messages
47
- * (from invalid validators) and null values (from valid validators)
48
- *
49
- * // { AbstractControl } control - control to validate
50
- * // { IValidatorFn[] } validators - array of validators
51
- * // { boolean } invert - invert?
52
- * // { PlainObject[] } - array of nulls and error message
53
- */
54
- export declare function _executeValidators(control: any, validators: any, invert?: boolean): any;
55
- /**
56
- * '_executeAsyncValidators' utility function
57
- *
58
- * Validates a control against an array of async validators, and returns
59
- * an array of observabe results of the same length containing a combination of
60
- * error messages (from invalid validators) and null values (from valid ones)
61
- *
62
- * // { AbstractControl } control - control to validate
63
- * // { AsyncIValidatorFn[] } validators - array of async validators
64
- * // { boolean } invert - invert?
65
- * // - array of observable nulls and error message
66
- */
67
- export declare function _executeAsyncValidators(control: any, validators: any, invert?: boolean): any;
68
- /**
69
- * '_mergeObjects' utility function
70
- *
71
- * Recursively Merges one or more objects into a single object with combined keys.
72
- * Automatically detects and ignores null and undefined inputs.
73
- * Also detects duplicated boolean 'not' keys and XORs their values.
74
- *
75
- * // { PlainObject[] } objects - one or more objects to merge
76
- * // { PlainObject } - merged object
77
- */
78
- export declare function _mergeObjects(...objects: any[]): PlainObject;
79
- /**
80
- * '_mergeErrors' utility function
81
- *
82
- * Merges an array of objects.
83
- * Used for combining the validator errors returned from 'executeValidators'
84
- *
85
- * // { PlainObject[] } arrayOfErrors - array of objects
86
- * // { PlainObject } - merged object, or null if no usable input objectcs
87
- */
88
- export declare function _mergeErrors(arrayOfErrors: any): PlainObject;
89
- /**
90
- * 'isDefined' utility function
91
- *
92
- * Checks if a variable contains a value of any type.
93
- * Returns true even for otherwise 'falsey' values of 0, '', and false.
94
- *
95
- * // value - the value to check
96
- * // { boolean } - false if undefined or null, otherwise true
97
- */
98
- export declare function isDefined(value: any): boolean;
99
- /**
100
- * 'hasValue' utility function
101
- *
102
- * Checks if a variable contains a value.
103
- * Returs false for null, undefined, or a zero-length strng, '',
104
- * otherwise returns true.
105
- * (Stricter than 'isDefined' because it also returns false for '',
106
- * though it stil returns true for otherwise 'falsey' values 0 and false.)
107
- *
108
- * // value - the value to check
109
- * // { boolean } - false if undefined, null, or '', otherwise true
110
- */
111
- export declare function hasValue(value: any): boolean;
112
- /**
113
- * 'isEmpty' utility function
114
- *
115
- * Similar to !hasValue, but also returns true for empty arrays and objects.
116
- *
117
- * // value - the value to check
118
- * // { boolean } - false if undefined, null, or '', otherwise true
119
- */
120
- export declare function isEmpty(value: any): boolean;
121
- /**
122
- * 'isString' utility function
123
- *
124
- * Checks if a value is a string.
125
- *
126
- * // value - the value to check
127
- * // { boolean } - true if string, false if not
128
- */
129
- export declare function isString(value: any): boolean;
130
- /**
131
- * 'isNumber' utility function
132
- *
133
- * Checks if a value is a regular number, numeric string, or JavaScript Date.
134
- *
135
- * // value - the value to check
136
- * // { any = false } strict - if truthy, also checks JavaScript tyoe
137
- * // { boolean } - true if number, false if not
138
- */
139
- export declare function isNumber(value: any, strict?: any): boolean;
140
- /**
141
- * 'isInteger' utility function
142
- *
143
- * Checks if a value is an integer.
144
- *
145
- * // value - the value to check
146
- * // { any = false } strict - if truthy, also checks JavaScript tyoe
147
- * // {boolean } - true if number, false if not
148
- */
149
- export declare function isInteger(value: any, strict?: any): boolean;
150
- /**
151
- * 'isBoolean' utility function
152
- *
153
- * Checks if a value is a boolean.
154
- *
155
- * // value - the value to check
156
- * // { any = null } option - if 'strict', also checks JavaScript type
157
- * if TRUE or FALSE, checks only for that value
158
- * // { boolean } - true if boolean, false if not
159
- */
160
- export declare function isBoolean(value: any, option?: any): boolean;
161
- export declare function isFunction(item: any): boolean;
162
- export declare function isObject(item: any): boolean;
163
- export declare function isArray(item: any): boolean;
164
- export declare function isDate(item: any): boolean;
165
- export declare function isMap(item: any): boolean;
166
- export declare function isSet(item: any): boolean;
167
- export declare function isSymbol(item: any): boolean;
168
- /**
169
- * 'getType' function
170
- *
171
- * Detects the JSON Schema Type of a value.
172
- * By default, detects numbers and integers even if formatted as strings.
173
- * (So all integers are also numbers, and any number may also be a string.)
174
- * However, it only detects true boolean values (to detect boolean values
175
- * in non-boolean formats, use isBoolean() instead).
176
- *
177
- * If passed a second optional parameter of 'strict', it will only detect
178
- * numbers and integers if they are formatted as JavaScript numbers.
179
- *
180
- * Examples:
181
- * getType('10.5') = 'number'
182
- * getType(10.5) = 'number'
183
- * getType('10') = 'integer'
184
- * getType(10) = 'integer'
185
- * getType('true') = 'string'
186
- * getType(true) = 'boolean'
187
- * getType(null) = 'null'
188
- * getType({ }) = 'object'
189
- * getType([]) = 'array'
190
- *
191
- * getType('10.5', 'strict') = 'string'
192
- * getType(10.5, 'strict') = 'number'
193
- * getType('10', 'strict') = 'string'
194
- * getType(10, 'strict') = 'integer'
195
- * getType('true', 'strict') = 'string'
196
- * getType(true, 'strict') = 'boolean'
197
- *
198
- * // value - value to check
199
- * // { any = false } strict - if truthy, also checks JavaScript tyoe
200
- * // { SchemaType }
201
- */
202
- export declare function getType(value: any, strict?: any): "string" | "number" | "integer" | "boolean" | "null" | "object" | "array";
203
- /**
204
- * 'isType' function
205
- *
206
- * Checks wether an input (probably string) value contains data of
207
- * a specified JSON Schema type
208
- *
209
- * // { PrimitiveValue } value - value to check
210
- * // { SchemaPrimitiveType } type - type to check
211
- * // { boolean }
212
- */
213
- export declare function isType(value: any, type: any): boolean;
214
- /**
215
- * 'isPrimitive' function
216
- *
217
- * Checks wether an input value is a JavaScript primitive type:
218
- * string, number, boolean, or null.
219
- *
220
- * // value - value to check
221
- * // { boolean }
222
- */
223
- export declare function isPrimitive(value: any): boolean;
224
- /**
225
- *
226
- * @param date
227
- * @returns {string}
228
- * exmaple:
229
- * toDateString('2018-01-01') = '2018-01-01'
230
- * toDateString('2018-01-30T00:00:00.000Z') = '2018-01-30'
231
- */
232
- export declare const toIsoString: (date: Date) => string;
233
- /**
234
- * 'toJavaScriptType' function
235
- *
236
- * Converts an input (probably string) value to a JavaScript primitive type -
237
- * 'string', 'number', 'boolean', or 'null' - before storing in a JSON object.
238
- *
239
- * Does not coerce values (other than null), and only converts the types
240
- * of values that would otherwise be valid.
241
- *
242
- * If the optional third parameter 'strictIntegers' is TRUE, and the
243
- * JSON Schema type 'integer' is specified, it also verifies the input value
244
- * is an integer and, if it is, returns it as a JaveScript number.
245
- * If 'strictIntegers' is FALSE (or not set) the type 'integer' is treated
246
- * exactly the same as 'number', and allows decimals.
247
- *
248
- * Valid Examples:
249
- * toJavaScriptType('10', 'number' ) = 10 // '10' is a number
250
- * toJavaScriptType('10', 'integer') = 10 // '10' is also an integer
251
- * toJavaScriptType( 10, 'integer') = 10 // 10 is still an integer
252
- * toJavaScriptType( 10, 'string' ) = '10' // 10 can be made into a string
253
- * toJavaScriptType('10.5', 'number' ) = 10.5 // '10.5' is a number
254
- *
255
- * Invalid Examples:
256
- * toJavaScriptType('10.5', 'integer') = null // '10.5' is not an integer
257
- * toJavaScriptType( 10.5, 'integer') = null // 10.5 is still not an integer
258
- *
259
- * // { PrimitiveValue } value - value to convert
260
- * // { SchemaPrimitiveType | SchemaPrimitiveType[] } types - types to convert to
261
- * // { boolean = false } strictIntegers - if FALSE, treat integers as numbers
262
- * // { PrimitiveValue }
263
- */
264
- export declare function toJavaScriptType(value: any, types: any, strictIntegers?: boolean): any;
265
- /**
266
- * 'toSchemaType' function
267
- *
268
- * Converts an input (probably string) value to the "best" JavaScript
269
- * equivalent available from an allowed list of JSON Schema types, which may
270
- * contain 'string', 'number', 'integer', 'boolean', and/or 'null'.
271
- * If necssary, it does progressively agressive type coersion.
272
- * It will not return null unless null is in the list of allowed types.
273
- *
274
- * Number conversion examples:
275
- * toSchemaType('10', ['number','integer','string']) = 10 // integer
276
- * toSchemaType('10', ['number','string']) = 10 // number
277
- * toSchemaType('10', ['string']) = '10' // string
278
- * toSchemaType('10.5', ['number','integer','string']) = 10.5 // number
279
- * toSchemaType('10.5', ['integer','string']) = '10.5' // string
280
- * toSchemaType('10.5', ['integer']) = 10 // integer
281
- * toSchemaType(10.5, ['null','boolean','string']) = '10.5' // string
282
- * toSchemaType(10.5, ['null','boolean']) = true // boolean
283
- *
284
- * String conversion examples:
285
- * toSchemaType('1.5x', ['boolean','number','integer','string']) = '1.5x' // string
286
- * toSchemaType('1.5x', ['boolean','number','integer']) = '1.5' // number
287
- * toSchemaType('1.5x', ['boolean','integer']) = '1' // integer
288
- * toSchemaType('1.5x', ['boolean']) = true // boolean
289
- * toSchemaType('xyz', ['number','integer','boolean','null']) = true // boolean
290
- * toSchemaType('xyz', ['number','integer','null']) = null // null
291
- * toSchemaType('xyz', ['number','integer']) = 0 // number
292
- *
293
- * Boolean conversion examples:
294
- * toSchemaType('1', ['integer','number','string','boolean']) = 1 // integer
295
- * toSchemaType('1', ['number','string','boolean']) = 1 // number
296
- * toSchemaType('1', ['string','boolean']) = '1' // string
297
- * toSchemaType('1', ['boolean']) = true // boolean
298
- * toSchemaType('true', ['number','string','boolean']) = 'true' // string
299
- * toSchemaType('true', ['boolean']) = true // boolean
300
- * toSchemaType('true', ['number']) = 0 // number
301
- * toSchemaType(true, ['number','string','boolean']) = true // boolean
302
- * toSchemaType(true, ['number','string']) = 'true' // string
303
- * toSchemaType(true, ['number']) = 1 // number
304
- *
305
- * // { PrimitiveValue } value - value to convert
306
- * // { SchemaPrimitiveType | SchemaPrimitiveType[] } types - allowed types to convert to
307
- * // { PrimitiveValue }
308
- */
309
- export declare function toSchemaType(value: any, types: any): any;
310
- /**
311
- * 'isPromise' function
312
- *
313
- * // object
314
- * // { boolean }
315
- */
316
- export declare function isPromise(object: any): object is Promise<any>;
317
- /**
318
- * 'isObservable' function
319
- *
320
- * // object
321
- * // { boolean }
322
- */
323
- export declare function isObservable(object: any): object is Observable<any>;
324
- /**
325
- * '_toPromise' function
326
- *
327
- * // { object } object
328
- * // { Promise<any> }
329
- */
330
- export declare function _toPromise(object: any): Promise<any>;
331
- /**
332
- * 'toObservable' function
333
- *
334
- * // { object } object
335
- * // { Observable<any> }
336
- */
337
- export declare function toObservable(object: any): Observable<any>;
338
- /**
339
- * 'inArray' function
340
- *
341
- * Searches an array for an item, or one of a list of items, and returns true
342
- * as soon as a match is found, or false if no match.
343
- *
344
- * If the optional third parameter allIn is set to TRUE, and the item to find
345
- * is an array, then the function returns true only if all elements from item
346
- * are found in the array list, and false if any element is not found. If the
347
- * item to find is not an array, setting allIn to TRUE has no effect.
348
- *
349
- * // { any|any[] } item - the item to search for
350
- * // array - the array to search
351
- * // { boolean = false } allIn - if TRUE, all items must be in array
352
- * // { boolean } - true if item(s) in array, false otherwise
353
- */
354
- export declare function inArray(item: any, array: any, allIn?: boolean): any;
355
- /**
356
- * 'xor' utility function - exclusive or
357
- *
358
- * Returns true if exactly one of two values is truthy.
359
- *
360
- * // value1 - first value to check
361
- * // value2 - second value to check
362
- * // { boolean } - true if exactly one input value is truthy, false if not
363
- */
364
- export declare function xor(value1: any, value2: any): boolean;
1
+ import { AbstractControl } from '@angular/forms';
2
+ import { Observable } from 'rxjs';
3
+ /**
4
+ * Validator utility function library:
5
+ *
6
+ * Validator and error utilities:
7
+ * _executeValidators, _executeAsyncValidators, _mergeObjects, _mergeErrors
8
+ *
9
+ * Individual value checking:
10
+ * isDefined, hasValue, isEmpty
11
+ *
12
+ * Individual type checking:
13
+ * isString, isNumber, isInteger, isBoolean, isFunction, isObject, isArray,
14
+ * isMap, isSet, isPromise, isObservable
15
+ *
16
+ * Multiple type checking and fixing:
17
+ * getType, isType, isPrimitive, toJavaScriptType, toSchemaType,
18
+ * _toPromise, toObservable
19
+ *
20
+ * Utility functions:
21
+ * inArray, xor
22
+ *
23
+ * Typescript types and interfaces:
24
+ * SchemaPrimitiveType, SchemaType, JavaScriptPrimitiveType, JavaScriptType,
25
+ * PrimitiveValue, PlainObject, IValidatorFn, AsyncIValidatorFn
26
+ *
27
+ * Note: 'IValidatorFn' is short for 'invertable validator function',
28
+ * which is a validator functions that accepts an optional second
29
+ * argument which, if set to TRUE, causes the validator to perform
30
+ * the opposite of its original function.
31
+ */
32
+ export type SchemaPrimitiveType = 'string' | 'number' | 'integer' | 'boolean' | 'null';
33
+ export type SchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'null' | 'object' | 'array';
34
+ export type JavaScriptPrimitiveType = 'string' | 'number' | 'boolean' | 'null' | 'undefined';
35
+ export type JavaScriptType = 'string' | 'number' | 'boolean' | 'null' | 'undefined' | 'object' | 'array' | 'map' | 'set' | 'arguments' | 'date' | 'error' | 'function' | 'json' | 'math' | 'regexp';
36
+ export type PrimitiveValue = string | number | boolean | null | undefined;
37
+ export interface PlainObject {
38
+ [k: string]: any;
39
+ }
40
+ export type IValidatorFn = (c: AbstractControl, i?: boolean) => PlainObject;
41
+ export type AsyncIValidatorFn = (c: AbstractControl, i?: boolean) => any;
42
+ /**
43
+ * '_executeValidators' utility function
44
+ *
45
+ * Validates a control against an array of validators, and returns
46
+ * an array of the same length containing a combination of error messages
47
+ * (from invalid validators) and null values (from valid validators)
48
+ *
49
+ * // { AbstractControl } control - control to validate
50
+ * // { IValidatorFn[] } validators - array of validators
51
+ * // { boolean } invert - invert?
52
+ * // { PlainObject[] } - array of nulls and error message
53
+ */
54
+ export declare function _executeValidators(control: any, validators: any, invert?: boolean): any;
55
+ /**
56
+ * '_executeAsyncValidators' utility function
57
+ *
58
+ * Validates a control against an array of async validators, and returns
59
+ * an array of observabe results of the same length containing a combination of
60
+ * error messages (from invalid validators) and null values (from valid ones)
61
+ *
62
+ * // { AbstractControl } control - control to validate
63
+ * // { AsyncIValidatorFn[] } validators - array of async validators
64
+ * // { boolean } invert - invert?
65
+ * // - array of observable nulls and error message
66
+ */
67
+ export declare function _executeAsyncValidators(control: any, validators: any, invert?: boolean): any;
68
+ /**
69
+ * '_mergeObjects' utility function
70
+ *
71
+ * Recursively Merges one or more objects into a single object with combined keys.
72
+ * Automatically detects and ignores null and undefined inputs.
73
+ * Also detects duplicated boolean 'not' keys and XORs their values.
74
+ *
75
+ * // { PlainObject[] } objects - one or more objects to merge
76
+ * // { PlainObject } - merged object
77
+ */
78
+ export declare function _mergeObjects(...objects: any[]): PlainObject;
79
+ /**
80
+ * '_mergeErrors' utility function
81
+ *
82
+ * Merges an array of objects.
83
+ * Used for combining the validator errors returned from 'executeValidators'
84
+ *
85
+ * // { PlainObject[] } arrayOfErrors - array of objects
86
+ * // { PlainObject } - merged object, or null if no usable input objectcs
87
+ */
88
+ export declare function _mergeErrors(arrayOfErrors: any): PlainObject;
89
+ /**
90
+ * 'isDefined' utility function
91
+ *
92
+ * Checks if a variable contains a value of any type.
93
+ * Returns true even for otherwise 'falsey' values of 0, '', and false.
94
+ *
95
+ * // value - the value to check
96
+ * // { boolean } - false if undefined or null, otherwise true
97
+ */
98
+ export declare function isDefined(value: any): boolean;
99
+ /**
100
+ * 'hasValue' utility function
101
+ *
102
+ * Checks if a variable contains a value.
103
+ * Returs false for null, undefined, or a zero-length strng, '',
104
+ * otherwise returns true.
105
+ * (Stricter than 'isDefined' because it also returns false for '',
106
+ * though it stil returns true for otherwise 'falsey' values 0 and false.)
107
+ *
108
+ * // value - the value to check
109
+ * // { boolean } - false if undefined, null, or '', otherwise true
110
+ */
111
+ export declare function hasValue(value: any): boolean;
112
+ /**
113
+ * 'isEmpty' utility function
114
+ *
115
+ * Similar to !hasValue, but also returns true for empty arrays and objects.
116
+ *
117
+ * // value - the value to check
118
+ * // { boolean } - false if undefined, null, or '', otherwise true
119
+ */
120
+ export declare function isEmpty(value: any): boolean;
121
+ /**
122
+ * 'isString' utility function
123
+ *
124
+ * Checks if a value is a string.
125
+ *
126
+ * // value - the value to check
127
+ * // { boolean } - true if string, false if not
128
+ */
129
+ export declare function isString(value: any): boolean;
130
+ /**
131
+ * 'isNumber' utility function
132
+ *
133
+ * Checks if a value is a regular number, numeric string, or JavaScript Date.
134
+ *
135
+ * // value - the value to check
136
+ * // { any = false } strict - if truthy, also checks JavaScript tyoe
137
+ * // { boolean } - true if number, false if not
138
+ */
139
+ export declare function isNumber(value: any, strict?: any): boolean;
140
+ /**
141
+ * 'isInteger' utility function
142
+ *
143
+ * Checks if a value is an integer.
144
+ *
145
+ * // value - the value to check
146
+ * // { any = false } strict - if truthy, also checks JavaScript tyoe
147
+ * // {boolean } - true if number, false if not
148
+ */
149
+ export declare function isInteger(value: any, strict?: any): boolean;
150
+ /**
151
+ * 'isBoolean' utility function
152
+ *
153
+ * Checks if a value is a boolean.
154
+ *
155
+ * // value - the value to check
156
+ * // { any = null } option - if 'strict', also checks JavaScript type
157
+ * if TRUE or FALSE, checks only for that value
158
+ * // { boolean } - true if boolean, false if not
159
+ */
160
+ export declare function isBoolean(value: any, option?: any): boolean;
161
+ export declare function isFunction(item: any): boolean;
162
+ export declare function isObject(item: any): boolean;
163
+ export declare function isArray(item: any): boolean;
164
+ export declare function isDate(item: any): boolean;
165
+ export declare function isMap(item: any): boolean;
166
+ export declare function isSet(item: any): boolean;
167
+ export declare function isSymbol(item: any): boolean;
168
+ /**
169
+ * 'getType' function
170
+ *
171
+ * Detects the JSON Schema Type of a value.
172
+ * By default, detects numbers and integers even if formatted as strings.
173
+ * (So all integers are also numbers, and any number may also be a string.)
174
+ * However, it only detects true boolean values (to detect boolean values
175
+ * in non-boolean formats, use isBoolean() instead).
176
+ *
177
+ * If passed a second optional parameter of 'strict', it will only detect
178
+ * numbers and integers if they are formatted as JavaScript numbers.
179
+ *
180
+ * Examples:
181
+ * getType('10.5') = 'number'
182
+ * getType(10.5) = 'number'
183
+ * getType('10') = 'integer'
184
+ * getType(10) = 'integer'
185
+ * getType('true') = 'string'
186
+ * getType(true) = 'boolean'
187
+ * getType(null) = 'null'
188
+ * getType({ }) = 'object'
189
+ * getType([]) = 'array'
190
+ *
191
+ * getType('10.5', 'strict') = 'string'
192
+ * getType(10.5, 'strict') = 'number'
193
+ * getType('10', 'strict') = 'string'
194
+ * getType(10, 'strict') = 'integer'
195
+ * getType('true', 'strict') = 'string'
196
+ * getType(true, 'strict') = 'boolean'
197
+ *
198
+ * // value - value to check
199
+ * // { any = false } strict - if truthy, also checks JavaScript tyoe
200
+ * // { SchemaType }
201
+ */
202
+ export declare function getType(value: any, strict?: any): "string" | "number" | "integer" | "boolean" | "null" | "object" | "array";
203
+ /**
204
+ * 'isType' function
205
+ *
206
+ * Checks wether an input (probably string) value contains data of
207
+ * a specified JSON Schema type
208
+ *
209
+ * // { PrimitiveValue } value - value to check
210
+ * // { SchemaPrimitiveType } type - type to check
211
+ * // { boolean }
212
+ */
213
+ export declare function isType(value: any, type: any): boolean;
214
+ /**
215
+ * 'isPrimitive' function
216
+ *
217
+ * Checks wether an input value is a JavaScript primitive type:
218
+ * string, number, boolean, or null.
219
+ *
220
+ * // value - value to check
221
+ * // { boolean }
222
+ */
223
+ export declare function isPrimitive(value: any): boolean;
224
+ /**
225
+ *
226
+ * @param date
227
+ * @returns {string}
228
+ * exmaple:
229
+ * toDateString('2018-01-01') = '2018-01-01'
230
+ * toDateString('2018-01-30T00:00:00.000Z') = '2018-01-30'
231
+ */
232
+ export declare const toIsoString: (date: Date) => string;
233
+ /**
234
+ * 'toJavaScriptType' function
235
+ *
236
+ * Converts an input (probably string) value to a JavaScript primitive type -
237
+ * 'string', 'number', 'boolean', or 'null' - before storing in a JSON object.
238
+ *
239
+ * Does not coerce values (other than null), and only converts the types
240
+ * of values that would otherwise be valid.
241
+ *
242
+ * If the optional third parameter 'strictIntegers' is TRUE, and the
243
+ * JSON Schema type 'integer' is specified, it also verifies the input value
244
+ * is an integer and, if it is, returns it as a JaveScript number.
245
+ * If 'strictIntegers' is FALSE (or not set) the type 'integer' is treated
246
+ * exactly the same as 'number', and allows decimals.
247
+ *
248
+ * Valid Examples:
249
+ * toJavaScriptType('10', 'number' ) = 10 // '10' is a number
250
+ * toJavaScriptType('10', 'integer') = 10 // '10' is also an integer
251
+ * toJavaScriptType( 10, 'integer') = 10 // 10 is still an integer
252
+ * toJavaScriptType( 10, 'string' ) = '10' // 10 can be made into a string
253
+ * toJavaScriptType('10.5', 'number' ) = 10.5 // '10.5' is a number
254
+ *
255
+ * Invalid Examples:
256
+ * toJavaScriptType('10.5', 'integer') = null // '10.5' is not an integer
257
+ * toJavaScriptType( 10.5, 'integer') = null // 10.5 is still not an integer
258
+ *
259
+ * // { PrimitiveValue } value - value to convert
260
+ * // { SchemaPrimitiveType | SchemaPrimitiveType[] } types - types to convert to
261
+ * // { boolean = false } strictIntegers - if FALSE, treat integers as numbers
262
+ * // { PrimitiveValue }
263
+ */
264
+ export declare function toJavaScriptType(value: any, types: any, strictIntegers?: boolean): any;
265
+ /**
266
+ * 'toSchemaType' function
267
+ *
268
+ * Converts an input (probably string) value to the "best" JavaScript
269
+ * equivalent available from an allowed list of JSON Schema types, which may
270
+ * contain 'string', 'number', 'integer', 'boolean', and/or 'null'.
271
+ * If necssary, it does progressively agressive type coersion.
272
+ * It will not return null unless null is in the list of allowed types.
273
+ *
274
+ * Number conversion examples:
275
+ * toSchemaType('10', ['number','integer','string']) = 10 // integer
276
+ * toSchemaType('10', ['number','string']) = 10 // number
277
+ * toSchemaType('10', ['string']) = '10' // string
278
+ * toSchemaType('10.5', ['number','integer','string']) = 10.5 // number
279
+ * toSchemaType('10.5', ['integer','string']) = '10.5' // string
280
+ * toSchemaType('10.5', ['integer']) = 10 // integer
281
+ * toSchemaType(10.5, ['null','boolean','string']) = '10.5' // string
282
+ * toSchemaType(10.5, ['null','boolean']) = true // boolean
283
+ *
284
+ * String conversion examples:
285
+ * toSchemaType('1.5x', ['boolean','number','integer','string']) = '1.5x' // string
286
+ * toSchemaType('1.5x', ['boolean','number','integer']) = '1.5' // number
287
+ * toSchemaType('1.5x', ['boolean','integer']) = '1' // integer
288
+ * toSchemaType('1.5x', ['boolean']) = true // boolean
289
+ * toSchemaType('xyz', ['number','integer','boolean','null']) = true // boolean
290
+ * toSchemaType('xyz', ['number','integer','null']) = null // null
291
+ * toSchemaType('xyz', ['number','integer']) = 0 // number
292
+ *
293
+ * Boolean conversion examples:
294
+ * toSchemaType('1', ['integer','number','string','boolean']) = 1 // integer
295
+ * toSchemaType('1', ['number','string','boolean']) = 1 // number
296
+ * toSchemaType('1', ['string','boolean']) = '1' // string
297
+ * toSchemaType('1', ['boolean']) = true // boolean
298
+ * toSchemaType('true', ['number','string','boolean']) = 'true' // string
299
+ * toSchemaType('true', ['boolean']) = true // boolean
300
+ * toSchemaType('true', ['number']) = 0 // number
301
+ * toSchemaType(true, ['number','string','boolean']) = true // boolean
302
+ * toSchemaType(true, ['number','string']) = 'true' // string
303
+ * toSchemaType(true, ['number']) = 1 // number
304
+ *
305
+ * // { PrimitiveValue } value - value to convert
306
+ * // { SchemaPrimitiveType | SchemaPrimitiveType[] } types - allowed types to convert to
307
+ * // { PrimitiveValue }
308
+ */
309
+ export declare function toSchemaType(value: any, types: any): any;
310
+ /**
311
+ * 'isPromise' function
312
+ *
313
+ * // object
314
+ * // { boolean }
315
+ */
316
+ export declare function isPromise(object: any): object is Promise<any>;
317
+ /**
318
+ * 'isObservable' function
319
+ *
320
+ * // object
321
+ * // { boolean }
322
+ */
323
+ export declare function isObservable(object: any): object is Observable<any>;
324
+ /**
325
+ * '_toPromise' function
326
+ *
327
+ * // { object } object
328
+ * // { Promise<any> }
329
+ */
330
+ export declare function _toPromise(object: any): Promise<any>;
331
+ /**
332
+ * 'toObservable' function
333
+ *
334
+ * // { object } object
335
+ * // { Observable<any> }
336
+ */
337
+ export declare function toObservable(object: any): Observable<any>;
338
+ /**
339
+ * 'inArray' function
340
+ *
341
+ * Searches an array for an item, or one of a list of items, and returns true
342
+ * as soon as a match is found, or false if no match.
343
+ *
344
+ * If the optional third parameter allIn is set to TRUE, and the item to find
345
+ * is an array, then the function returns true only if all elements from item
346
+ * are found in the array list, and false if any element is not found. If the
347
+ * item to find is not an array, setting allIn to TRUE has no effect.
348
+ *
349
+ * // { any|any[] } item - the item to search for
350
+ * // array - the array to search
351
+ * // { boolean = false } allIn - if TRUE, all items must be in array
352
+ * // { boolean } - true if item(s) in array, false otherwise
353
+ */
354
+ export declare function inArray(item: any, array: any, allIn?: boolean): any;
355
+ /**
356
+ * 'xor' utility function - exclusive or
357
+ *
358
+ * Returns true if exactly one of two values is truthy.
359
+ *
360
+ * // value1 - first value to check
361
+ * // value2 - second value to check
362
+ * // { boolean } - true if exactly one input value is truthy, false if not
363
+ */
364
+ export declare function xor(value1: any, value2: any): boolean;