@object-ui/core 17.6.0 → 18.0.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 (147) hide show
  1. package/CHANGELOG.md +7260 -0
  2. package/README.md +228 -14
  3. package/dist/actions/ActionEngine.d.ts +4 -2
  4. package/dist/actions/ActionEngine.js +13 -8
  5. package/dist/actions/ActionRunner.d.ts +473 -69
  6. package/dist/actions/ActionRunner.js +792 -125
  7. package/dist/actions/TransactionManager.d.ts +7 -2
  8. package/dist/actions/UndoManager.d.ts +8 -13
  9. package/dist/actions/actionKeys.d.ts +9 -7
  10. package/dist/actions/actionKeys.js +67 -14
  11. package/dist/actions/actionResponse.js +2 -2
  12. package/dist/actions/index.d.ts +2 -0
  13. package/dist/actions/index.js +2 -0
  14. package/dist/actions/navigationTarget.d.ts +41 -0
  15. package/dist/actions/navigationTarget.js +20 -0
  16. package/dist/actions/recordDelete.d.ts +154 -0
  17. package/dist/actions/recordDelete.js +110 -0
  18. package/dist/adapters/ApiDataSource.d.ts +8 -4
  19. package/dist/adapters/ApiDataSource.js +19 -7
  20. package/dist/adapters/ValueDataSource.d.ts +6 -1
  21. package/dist/adapters/ValueDataSource.js +1090 -98
  22. package/dist/adapters/batchTransaction.d.ts +1 -1
  23. package/dist/adapters/batchTransaction.js +1 -1
  24. package/dist/adapters/resolveDataSource.d.ts +9 -6
  25. package/dist/adapters/resolveDataSource.js +9 -12
  26. package/dist/builder/schema-builder.d.ts +38 -81
  27. package/dist/builder/schema-builder.js +33 -152
  28. package/dist/data-scope/ViewDataProvider.d.ts +8 -25
  29. package/dist/data-scope/ViewDataProvider.js +27 -54
  30. package/dist/data-scope/element-data-source.d.ts +261 -7
  31. package/dist/data-scope/element-data-source.js +342 -52
  32. package/dist/data-scope/index.d.ts +9 -4
  33. package/dist/data-scope/index.js +9 -4
  34. package/dist/evaluator/ExpressionEvaluator.d.ts +86 -0
  35. package/dist/evaluator/ExpressionEvaluator.js +184 -12
  36. package/dist/evaluator/FormulaFunctions.d.ts +0 -10
  37. package/dist/evaluator/FormulaFunctions.js +166 -27
  38. package/dist/evaluator/deadlineSettled.d.ts +40 -0
  39. package/dist/evaluator/deadlineSettled.js +45 -0
  40. package/dist/evaluator/declaredPredicate.d.ts +93 -9
  41. package/dist/evaluator/declaredPredicate.js +117 -16
  42. package/dist/evaluator/fieldRules.d.ts +88 -4
  43. package/dist/evaluator/fieldRules.js +208 -31
  44. package/dist/evaluator/index.d.ts +2 -0
  45. package/dist/evaluator/index.js +2 -0
  46. package/dist/evaluator/listConditional.d.ts +103 -34
  47. package/dist/evaluator/listConditional.js +127 -50
  48. package/dist/evaluator/optionRules.d.ts +77 -6
  49. package/dist/evaluator/optionRules.js +87 -10
  50. package/dist/evaluator/predicateInput.d.ts +15 -4
  51. package/dist/evaluator/predicateInput.js +35 -2
  52. package/dist/evaluator/rowPredicateCanon.d.ts +7 -18
  53. package/dist/evaluator/rowPredicateCanon.js +65 -115
  54. package/dist/evaluator/subjectPermissions.d.ts +105 -0
  55. package/dist/evaluator/subjectPermissions.js +86 -0
  56. package/dist/evaluator/unevaluablePredicate.d.ts +57 -0
  57. package/dist/evaluator/unevaluablePredicate.js +70 -0
  58. package/dist/index.d.ts +15 -0
  59. package/dist/index.js +83 -2
  60. package/dist/protocols/index.d.ts +0 -1
  61. package/dist/protocols/index.js +9 -1
  62. package/dist/registry/Registry.d.ts +382 -34
  63. package/dist/registry/Registry.js +247 -12
  64. package/dist/registry/WidgetRegistry.js +7 -3
  65. package/dist/registry/html-tier-intrinsics.d.ts +90 -0
  66. package/dist/registry/html-tier-intrinsics.js +110 -0
  67. package/dist/registry/public-blocks.d.ts +8 -0
  68. package/dist/registry/public-blocks.js +57 -0
  69. package/dist/theme/ThemeEngine.js +1 -1
  70. package/dist/utils/affordanceGrants.d.ts +371 -0
  71. package/dist/utils/affordanceGrants.js +252 -0
  72. package/dist/utils/chart-category-key.d.ts +82 -0
  73. package/dist/utils/chart-category-key.js +84 -0
  74. package/dist/utils/chart-measure-key.d.ts +64 -0
  75. package/dist/utils/chart-measure-key.js +65 -0
  76. package/dist/utils/chart-presentation.d.ts +95 -112
  77. package/dist/utils/chart-presentation.js +169 -104
  78. package/dist/utils/chart-series.d.ts +165 -5
  79. package/dist/utils/chart-series.js +123 -18
  80. package/dist/utils/column-sortability.d.ts +157 -0
  81. package/dist/utils/column-sortability.js +217 -0
  82. package/dist/utils/dashboard-filters.d.ts +38 -6
  83. package/dist/utils/dashboard-filters.js +107 -61
  84. package/dist/utils/dataset-format.d.ts +211 -30
  85. package/dist/utils/dataset-format.js +389 -46
  86. package/dist/utils/date-display.d.ts +346 -0
  87. package/dist/utils/date-display.js +644 -0
  88. package/dist/utils/date-macros.js +7 -0
  89. package/dist/utils/drill-down.d.ts +78 -0
  90. package/dist/utils/drill-down.js +93 -0
  91. package/dist/utils/emptiness.d.ts +96 -0
  92. package/dist/utils/emptiness.js +101 -0
  93. package/dist/utils/expand-fields.d.ts +81 -9
  94. package/dist/utils/expand-fields.js +81 -9
  95. package/dist/utils/extract-records.d.ts +65 -5
  96. package/dist/utils/extract-records.js +65 -8
  97. package/dist/utils/filter-converter.d.ts +158 -6
  98. package/dist/utils/filter-converter.js +1098 -24
  99. package/dist/utils/filter-tokens.d.ts +49 -5
  100. package/dist/utils/filter-tokens.js +105 -33
  101. package/dist/utils/grouping-fields.d.ts +61 -0
  102. package/dist/utils/grouping-fields.js +84 -0
  103. package/dist/utils/managedBy.d.ts +3 -3
  104. package/dist/utils/managedBy.js +5 -5
  105. package/dist/utils/native-date-value.d.ts +48 -0
  106. package/dist/utils/native-date-value.js +167 -0
  107. package/dist/utils/non-grid-row-ceiling.d.ts +143 -0
  108. package/dist/utils/non-grid-row-ceiling.js +141 -0
  109. package/dist/utils/normalize-list-view.d.ts +135 -11
  110. package/dist/utils/normalize-list-view.js +243 -64
  111. package/dist/utils/number-display.d.ts +63 -14
  112. package/dist/utils/number-display.js +34 -12
  113. package/dist/utils/object-aggregate-query.d.ts +113 -0
  114. package/dist/utils/object-aggregate-query.js +50 -0
  115. package/dist/utils/parent-scope.d.ts +123 -0
  116. package/dist/utils/parent-scope.js +140 -0
  117. package/dist/utils/predicate-fields.d.ts +45 -12
  118. package/dist/utils/predicate-fields.js +141 -12
  119. package/dist/utils/record-color.d.ts +75 -0
  120. package/dist/utils/record-color.js +65 -0
  121. package/dist/utils/record-source.d.ts +298 -0
  122. package/dist/utils/record-source.js +331 -0
  123. package/dist/utils/record-title.d.ts +148 -8
  124. package/dist/utils/record-title.js +220 -26
  125. package/dist/utils/reference-keys.d.ts +21 -22
  126. package/dist/utils/reference-keys.js +532 -29
  127. package/dist/utils/sort-query.d.ts +115 -15
  128. package/dist/utils/sort-query.js +240 -13
  129. package/dist/utils/text-comparand.d.ts +92 -0
  130. package/dist/utils/text-comparand.js +99 -0
  131. package/dist/utils/without-denied-fields.d.ts +49 -0
  132. package/dist/utils/without-denied-fields.js +52 -0
  133. package/dist/validation/index.d.ts +8 -4
  134. package/dist/validation/index.js +8 -4
  135. package/dist/validation/schema-validator.d.ts +1 -1
  136. package/dist/validation/schema-validator.js +225 -83
  137. package/dist/validation/server-owned-value.d.ts +5 -1
  138. package/dist/validation/server-owned-value.js +5 -1
  139. package/dist/validation/validators/object-validation-engine.d.ts +1 -1
  140. package/dist/validation/validators/object-validation-engine.js +14 -3
  141. package/package.json +8 -9
  142. package/dist/data-scope/DataScopeManager.d.ts +0 -127
  143. package/dist/data-scope/DataScopeManager.js +0 -229
  144. package/dist/protocols/ResponsiveProtocol.d.ts +0 -73
  145. package/dist/protocols/ResponsiveProtocol.js +0 -158
  146. package/dist/validation/validation-engine.d.ts +0 -88
  147. package/dist/validation/validation-engine.js +0 -434
@@ -1,88 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- /**
9
- * @object-ui/core - Validation Engine
10
- *
11
- * Phase 3.5: Complete validation engine implementation with support for:
12
- * - Sync and async validation
13
- * - Cross-field validation
14
- * - Custom validation functions
15
- * - Improved error messages
16
- *
17
- * @module validation-engine
18
- * @packageDocumentation
19
- */
20
- import type { AdvancedValidationSchema, ValidationFunction, AsyncValidationFunction, ValidationContext, AdvancedValidationResult, AdvancedValidationError } from '@object-ui/types';
21
- /**
22
- * Validation Engine - Executes validation rules
23
- */
24
- export declare class ValidationEngine {
25
- private customValidators;
26
- private customAsyncValidators;
27
- /**
28
- * Register a custom synchronous validator by name
29
- */
30
- registerValidator(name: string, fn: ValidationFunction): void;
31
- /**
32
- * Register a custom asynchronous validator by name
33
- */
34
- registerAsyncValidator(name: string, fn: AsyncValidationFunction): void;
35
- /**
36
- * Check if a custom validator is registered
37
- */
38
- hasValidator(name: string): boolean;
39
- /**
40
- * Get all registered custom validator names
41
- */
42
- getValidatorNames(): string[];
43
- /**
44
- * Validate a value against validation schema
45
- */
46
- validate(value: any, schema: AdvancedValidationSchema, context?: ValidationContext): Promise<AdvancedValidationResult>;
47
- /**
48
- * Validate a single rule
49
- */
50
- private validateRule;
51
- /**
52
- * Validate built-in rules
53
- */
54
- private validateBuiltInRule;
55
- /**
56
- * Evaluate a condition
57
- * Note: Conditions must be declarative objects, not functions, for security.
58
- */
59
- private evaluateCondition;
60
- /**
61
- * Validate multiple fields
62
- */
63
- validateFields(values: Record<string, any>, schemas: Record<string, AdvancedValidationSchema>): Promise<Record<string, AdvancedValidationResult>>;
64
- /**
65
- * Check if all fields are valid
66
- */
67
- isValid(results: Record<string, AdvancedValidationResult>): boolean;
68
- /**
69
- * Get all errors from validation results
70
- */
71
- getAllErrors(results: Record<string, AdvancedValidationResult>): AdvancedValidationError[];
72
- /**
73
- * Get all warnings from validation results
74
- */
75
- getAllWarnings(results: Record<string, AdvancedValidationResult>): AdvancedValidationError[];
76
- }
77
- /**
78
- * Default validation engine instance
79
- */
80
- export declare const defaultValidationEngine: ValidationEngine;
81
- /**
82
- * Convenience function to validate a value
83
- */
84
- export declare function validate(value: any, schema: AdvancedValidationSchema, context?: ValidationContext): Promise<AdvancedValidationResult>;
85
- /**
86
- * Convenience function to validate multiple fields
87
- */
88
- export declare function validateFields(values: Record<string, any>, schemas: Record<string, AdvancedValidationSchema>): Promise<Record<string, AdvancedValidationResult>>;
@@ -1,434 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- /**
9
- * Validation Engine - Executes validation rules
10
- */
11
- export class ValidationEngine {
12
- constructor() {
13
- Object.defineProperty(this, "customValidators", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: new Map()
18
- });
19
- Object.defineProperty(this, "customAsyncValidators", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: new Map()
24
- });
25
- }
26
- /**
27
- * Register a custom synchronous validator by name
28
- */
29
- registerValidator(name, fn) {
30
- this.customValidators.set(name, fn);
31
- }
32
- /**
33
- * Register a custom asynchronous validator by name
34
- */
35
- registerAsyncValidator(name, fn) {
36
- this.customAsyncValidators.set(name, fn);
37
- }
38
- /**
39
- * Check if a custom validator is registered
40
- */
41
- hasValidator(name) {
42
- return this.customValidators.has(name) || this.customAsyncValidators.has(name);
43
- }
44
- /**
45
- * Get all registered custom validator names
46
- */
47
- getValidatorNames() {
48
- return [
49
- ...Array.from(this.customValidators.keys()),
50
- ...Array.from(this.customAsyncValidators.keys()),
51
- ];
52
- }
53
- /**
54
- * Validate a value against validation schema
55
- */
56
- async validate(value, schema, context) {
57
- const errors = [];
58
- const warnings = [];
59
- for (const rule of schema.rules) {
60
- const result = await this.validateRule(value, rule, context);
61
- if (result) {
62
- const error = {
63
- field: schema.field || 'unknown',
64
- message: result,
65
- code: rule.type,
66
- rule: rule.type,
67
- severity: rule.severity || 'error',
68
- };
69
- if (rule.severity === 'warning' || rule.severity === 'info') {
70
- warnings.push(error);
71
- }
72
- else {
73
- errors.push(error);
74
- }
75
- }
76
- }
77
- return {
78
- valid: errors.length === 0,
79
- errors,
80
- warnings,
81
- };
82
- }
83
- /**
84
- * Validate a single rule
85
- */
86
- async validateRule(value, rule, context) {
87
- // Custom async validator (inline)
88
- if (rule.async_validator) {
89
- const result = await rule.async_validator(value, context);
90
- if (result === false) {
91
- return rule.message || 'Async validation failed';
92
- }
93
- if (typeof result === 'string') {
94
- return result;
95
- }
96
- return null;
97
- }
98
- // Custom sync validator (inline)
99
- if (rule.validator) {
100
- const result = rule.validator(value, context);
101
- if (result === false) {
102
- return rule.message || 'Validation failed';
103
- }
104
- if (typeof result === 'string') {
105
- return result;
106
- }
107
- return null;
108
- }
109
- // Registered custom async validator (by name)
110
- const registeredAsync = this.customAsyncValidators.get(rule.type);
111
- if (registeredAsync) {
112
- const result = await registeredAsync(value, context);
113
- if (result === false) {
114
- return rule.message || 'Async validation failed';
115
- }
116
- if (typeof result === 'string') {
117
- return result;
118
- }
119
- return null;
120
- }
121
- // Registered custom sync validator (by name)
122
- const registeredSync = this.customValidators.get(rule.type);
123
- if (registeredSync) {
124
- const result = registeredSync(value, context);
125
- if (result === false) {
126
- return rule.message || 'Validation failed';
127
- }
128
- if (typeof result === 'string') {
129
- return result;
130
- }
131
- return null;
132
- }
133
- // Built-in validators
134
- return this.validateBuiltInRule(value, rule, context);
135
- }
136
- /**
137
- * Validate built-in rules
138
- */
139
- async validateBuiltInRule(value, rule, context) {
140
- const { type, params, message } = rule;
141
- switch (type) {
142
- case 'required':
143
- if (value === null || value === undefined || value === '') {
144
- return message || 'This field is required';
145
- }
146
- break;
147
- case 'min_length':
148
- if (typeof value === 'string' && value.length < params) {
149
- return message || `Minimum length is ${params} characters`;
150
- }
151
- break;
152
- case 'max_length':
153
- if (typeof value === 'string' && value.length > params) {
154
- return message || `Maximum length is ${params} characters`;
155
- }
156
- break;
157
- case 'pattern':
158
- if (typeof value === 'string') {
159
- try {
160
- const regex = typeof params === 'string' ? new RegExp(params) : params;
161
- if (!regex.test(value)) {
162
- return message || 'Invalid format';
163
- }
164
- }
165
- catch (error) {
166
- return message || 'Invalid pattern configuration';
167
- }
168
- }
169
- break;
170
- case 'email':
171
- if (typeof value === 'string') {
172
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
173
- if (!emailRegex.test(value)) {
174
- return message || 'Invalid email address';
175
- }
176
- }
177
- break;
178
- case 'url':
179
- if (typeof value === 'string') {
180
- try {
181
- new URL(value);
182
- }
183
- catch {
184
- return message || 'Invalid URL';
185
- }
186
- }
187
- break;
188
- case 'phone':
189
- if (typeof value === 'string') {
190
- const phoneRegex = /^[\d\s\-+()]+$/;
191
- if (!phoneRegex.test(value)) {
192
- return message || 'Invalid phone number';
193
- }
194
- }
195
- break;
196
- case 'min':
197
- if (typeof value === 'number' && value < params) {
198
- return message || `Minimum value is ${params}`;
199
- }
200
- break;
201
- case 'max':
202
- if (typeof value === 'number' && value > params) {
203
- return message || `Maximum value is ${params}`;
204
- }
205
- break;
206
- case 'integer':
207
- if (typeof value === 'number' && !Number.isInteger(value)) {
208
- return message || 'Value must be an integer';
209
- }
210
- break;
211
- case 'positive':
212
- if (typeof value === 'number' && value <= 0) {
213
- return message || 'Value must be positive';
214
- }
215
- break;
216
- case 'negative':
217
- if (typeof value === 'number' && value >= 0) {
218
- return message || 'Value must be negative';
219
- }
220
- break;
221
- case 'date_min':
222
- if (value instanceof Date || typeof value === 'string') {
223
- const date = value instanceof Date ? value : new Date(value);
224
- const minDate = params instanceof Date ? params : new Date(params);
225
- if (date < minDate) {
226
- return message || `Date must be after ${minDate.toLocaleDateString()}`;
227
- }
228
- }
229
- break;
230
- case 'date_max':
231
- if (value instanceof Date || typeof value === 'string') {
232
- const date = value instanceof Date ? value : new Date(value);
233
- const maxDate = params instanceof Date ? params : new Date(params);
234
- if (date > maxDate) {
235
- return message || `Date must be before ${maxDate.toLocaleDateString()}`;
236
- }
237
- }
238
- break;
239
- case 'date_future':
240
- if (value instanceof Date || typeof value === 'string') {
241
- const date = value instanceof Date ? value : new Date(value);
242
- if (date <= new Date()) {
243
- return message || 'Date must be in the future';
244
- }
245
- }
246
- break;
247
- case 'date_past':
248
- if (value instanceof Date || typeof value === 'string') {
249
- const date = value instanceof Date ? value : new Date(value);
250
- if (date >= new Date()) {
251
- return message || 'Date must be in the past';
252
- }
253
- }
254
- break;
255
- case 'min_items':
256
- if (Array.isArray(value) && value.length < params) {
257
- return message || `Minimum ${params} items required`;
258
- }
259
- break;
260
- case 'max_items':
261
- if (Array.isArray(value) && value.length > params) {
262
- return message || `Maximum ${params} items allowed`;
263
- }
264
- break;
265
- case 'unique_items':
266
- if (Array.isArray(value)) {
267
- const unique = new Set(value);
268
- if (unique.size !== value.length) {
269
- return message || 'All items must be unique';
270
- }
271
- }
272
- break;
273
- case 'field_match':
274
- if (context?.values && params) {
275
- const otherValue = context.values[params];
276
- if (value !== otherValue) {
277
- return message || `Value must match ${params}`;
278
- }
279
- }
280
- break;
281
- case 'field_compare':
282
- if (context?.values && params) {
283
- const { field: otherField, operator } = params;
284
- const otherValue = context.values[otherField];
285
- switch (operator) {
286
- case '>':
287
- if (value <= otherValue) {
288
- return message || `Value must be greater than ${otherField}`;
289
- }
290
- break;
291
- case '<':
292
- if (value >= otherValue) {
293
- return message || `Value must be less than ${otherField}`;
294
- }
295
- break;
296
- case '>=':
297
- if (value < otherValue) {
298
- return message || `Value must be greater than or equal to ${otherField}`;
299
- }
300
- break;
301
- case '<=':
302
- if (value > otherValue) {
303
- return message || `Value must be less than or equal to ${otherField}`;
304
- }
305
- break;
306
- }
307
- }
308
- break;
309
- case 'conditional':
310
- if (context?.values && params) {
311
- const { condition, rules } = params;
312
- if (!Array.isArray(rules) || rules.length === 0) {
313
- break;
314
- }
315
- const conditionMet = this.evaluateCondition(condition, context.values);
316
- if (conditionMet) {
317
- for (const conditionalRule of rules) {
318
- const result = await this.validateRule(value, conditionalRule, context);
319
- if (result) {
320
- return result;
321
- }
322
- }
323
- }
324
- }
325
- break;
326
- default:
327
- // Unhandled validation rule type
328
- console.warn(`Unsupported validation rule type: ${type}`);
329
- return null;
330
- }
331
- return null;
332
- }
333
- /**
334
- * Evaluate a condition
335
- * Note: Conditions must be declarative objects, not functions, for security.
336
- */
337
- evaluateCondition(condition, values) {
338
- if (typeof condition === 'function') {
339
- console.warn('Function-based conditions are deprecated and will be removed. Use declarative conditions instead.\n\n' +
340
- ' Migration:\n' +
341
- ' // Before (deprecated):\n' +
342
- ' { condition: (values) => values.age > 18 }\n\n' +
343
- ' // After:\n' +
344
- ' { condition: { field: "age", operator: ">", value: 18 } }\n\n' +
345
- ' See: https://github.com/objectstack-ai/objectui/blob/main/MIGRATION_GUIDE.md');
346
- return false; // Security: reject function-based conditions
347
- }
348
- if (typeof condition === 'object' && condition.field) {
349
- const fieldValue = values[condition.field];
350
- const { operator = '=', value } = condition;
351
- switch (operator) {
352
- case '=':
353
- return fieldValue === value;
354
- case '!=':
355
- return fieldValue !== value;
356
- case '>':
357
- return fieldValue > value;
358
- case '<':
359
- return fieldValue < value;
360
- case '>=':
361
- return fieldValue >= value;
362
- case '<=':
363
- return fieldValue <= value;
364
- case 'in':
365
- return Array.isArray(value) && value.includes(fieldValue);
366
- default:
367
- return false;
368
- }
369
- }
370
- return false;
371
- }
372
- /**
373
- * Validate multiple fields
374
- */
375
- async validateFields(values, schemas) {
376
- const results = {};
377
- const context = {
378
- values,
379
- };
380
- for (const [field, schema] of Object.entries(schemas)) {
381
- const value = values[field];
382
- const schemaWithField = {
383
- ...schema,
384
- field: schema.field ?? field,
385
- };
386
- results[field] = await this.validate(value, schemaWithField, context);
387
- }
388
- return results;
389
- }
390
- /**
391
- * Check if all fields are valid
392
- */
393
- isValid(results) {
394
- return Object.values(results).every(result => result.valid);
395
- }
396
- /**
397
- * Get all errors from validation results
398
- */
399
- getAllErrors(results) {
400
- const errors = [];
401
- for (const result of Object.values(results)) {
402
- errors.push(...result.errors);
403
- }
404
- return errors;
405
- }
406
- /**
407
- * Get all warnings from validation results
408
- */
409
- getAllWarnings(results) {
410
- const warnings = [];
411
- for (const result of Object.values(results)) {
412
- if (result.warnings) {
413
- warnings.push(...result.warnings);
414
- }
415
- }
416
- return warnings;
417
- }
418
- }
419
- /**
420
- * Default validation engine instance
421
- */
422
- export const defaultValidationEngine = new ValidationEngine();
423
- /**
424
- * Convenience function to validate a value
425
- */
426
- export async function validate(value, schema, context) {
427
- return defaultValidationEngine.validate(value, schema, context);
428
- }
429
- /**
430
- * Convenience function to validate multiple fields
431
- */
432
- export async function validateFields(values, schemas) {
433
- return defaultValidationEngine.validateFields(values, schemas);
434
- }