@rjsf/validator-ajv8 5.6.2 → 5.7.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.
@@ -1,15 +1,18 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash-es/get'), require('@rjsf/utils'), require('ajv'), require('ajv-formats'), require('lodash-es/isObject')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'lodash-es/get', '@rjsf/utils', 'ajv', 'ajv-formats', 'lodash-es/isObject'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/validator-ajv8"] = {}, global.get, global.utils, global.Ajv, global.addFormats, global.isObject));
5
- })(this, (function (exports, get, utils, Ajv, addFormats, isObject) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rjsf/utils'), require('ajv'), require('ajv-formats'), require('lodash-es/isObject'), require('lodash-es/get'), require('fs'), require('ajv/dist/standalone'), require('lodash-es/isEqual')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@rjsf/utils', 'ajv', 'ajv-formats', 'lodash-es/isObject', 'lodash-es/get', 'fs', 'ajv/dist/standalone', 'lodash-es/isEqual'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/validator-ajv8"] = {}, global.utils, global.Ajv, global.addFormats, global.isObject, global.get, global.fs, global.standaloneCode, global.isEqual));
5
+ })(this, (function (exports, utils, Ajv, addFormats, isObject, get, fs, standaloneCode, isEqual) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
- var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
10
9
  var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
11
10
  var addFormats__default = /*#__PURE__*/_interopDefaultLegacy(addFormats);
12
11
  var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
12
+ var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
13
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
14
+ var standaloneCode__default = /*#__PURE__*/_interopDefaultLegacy(standaloneCode);
15
+ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
13
16
 
14
17
  function _extends() {
15
18
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -94,6 +97,110 @@
94
97
  }
95
98
 
96
99
  var _excluded = ["instancePath", "keyword", "params", "schemaPath", "parentSchema"];
100
+ /** Transforming the error output from ajv to format used by @rjsf/utils.
101
+ * At some point, components should be updated to support ajv.
102
+ *
103
+ * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`
104
+ * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
105
+ */
106
+ function transformRJSFValidationErrors(errors, uiSchema) {
107
+ if (errors === void 0) {
108
+ errors = [];
109
+ }
110
+ return errors.map(function (e) {
111
+ var instancePath = e.instancePath,
112
+ keyword = e.keyword,
113
+ params = e.params,
114
+ schemaPath = e.schemaPath,
115
+ parentSchema = e.parentSchema,
116
+ rest = _objectWithoutPropertiesLoose(e, _excluded);
117
+ var _rest$message = rest.message,
118
+ message = _rest$message === void 0 ? '' : _rest$message;
119
+ var property = instancePath.replace(/\//g, '.');
120
+ var stack = (property + " " + message).trim();
121
+ if ('missingProperty' in params) {
122
+ property = property ? property + "." + params.missingProperty : params.missingProperty;
123
+ var currentProperty = params.missingProperty;
124
+ var uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, "" + property.replace(/^\./, ''))).title;
125
+ if (uiSchemaTitle) {
126
+ message = message.replace(currentProperty, uiSchemaTitle);
127
+ } else {
128
+ var parentSchemaTitle = get__default["default"](parentSchema, [utils.PROPERTIES_KEY, currentProperty, 'title']);
129
+ if (parentSchemaTitle) {
130
+ message = message.replace(currentProperty, parentSchemaTitle);
131
+ }
132
+ }
133
+ stack = message;
134
+ } else {
135
+ var _uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, "" + property.replace(/^\./, ''))).title;
136
+ if (_uiSchemaTitle) {
137
+ stack = ("'" + _uiSchemaTitle + "' " + message).trim();
138
+ } else {
139
+ var _parentSchemaTitle = parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.title;
140
+ if (_parentSchemaTitle) {
141
+ stack = ("'" + _parentSchemaTitle + "' " + message).trim();
142
+ }
143
+ }
144
+ }
145
+ // put data in expected format
146
+ return {
147
+ name: keyword,
148
+ property: property,
149
+ message: message,
150
+ params: params,
151
+ stack: stack,
152
+ schemaPath: schemaPath
153
+ };
154
+ });
155
+ }
156
+ /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives
157
+ * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also
158
+ * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and
159
+ * transform them in what ever way it chooses.
160
+ *
161
+ * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call
162
+ * @param rawErrors - The list of raw `ErrorObject`s to process
163
+ * @param formData - The form data to validate
164
+ * @param schema - The schema against which to validate the form data
165
+ * @param [customValidate] - An optional function that is used to perform custom validation
166
+ * @param [transformErrors] - An optional function that is used to transform errors after AJV validation
167
+ * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
168
+ */
169
+ function processRawValidationErrors(validator, rawErrors, formData, schema, customValidate, transformErrors, uiSchema) {
170
+ var invalidSchemaError = rawErrors.validationError;
171
+ var errors = transformRJSFValidationErrors(rawErrors.errors, uiSchema);
172
+ if (invalidSchemaError) {
173
+ errors = [].concat(errors, [{
174
+ stack: invalidSchemaError.message
175
+ }]);
176
+ }
177
+ if (typeof transformErrors === 'function') {
178
+ errors = transformErrors(errors, uiSchema);
179
+ }
180
+ var errorSchema = utils.toErrorSchema(errors);
181
+ if (invalidSchemaError) {
182
+ errorSchema = _extends({}, errorSchema, {
183
+ $schema: {
184
+ __errors: [invalidSchemaError.message]
185
+ }
186
+ });
187
+ }
188
+ if (typeof customValidate !== 'function') {
189
+ return {
190
+ errors: errors,
191
+ errorSchema: errorSchema
192
+ };
193
+ }
194
+ // Include form data with undefined values, which is required for custom validation.
195
+ var newFormData = utils.getDefaultFormState(validator, schema, formData, schema, true);
196
+ var errorHandler = customValidate(newFormData, utils.createErrorHandler(newFormData), uiSchema);
197
+ var userErrorSchema = utils.unwrapErrorHandler(errorHandler);
198
+ return utils.validationDataMerge({
199
+ errors: errors,
200
+ errorSchema: errorSchema
201
+ }, userErrorSchema);
202
+ }
203
+
97
204
  /** `ValidatorType` implementation that uses the AJV 8 validation mechanism.
98
205
  */
99
206
  var AJV8Validator = /*#__PURE__*/function () {
@@ -135,63 +242,6 @@
135
242
  }
136
243
  return utils.toErrorList(errorSchema, fieldPath);
137
244
  }
138
- /** Transforming the error output from ajv to format used by @rjsf/utils.
139
- * At some point, components should be updated to support ajv.
140
- *
141
- * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`
142
- * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
143
- * @protected
144
- */;
145
- _proto.transformRJSFValidationErrors = function transformRJSFValidationErrors(errors, uiSchema) {
146
- if (errors === void 0) {
147
- errors = [];
148
- }
149
- return errors.map(function (e) {
150
- var instancePath = e.instancePath,
151
- keyword = e.keyword,
152
- params = e.params,
153
- schemaPath = e.schemaPath,
154
- parentSchema = e.parentSchema,
155
- rest = _objectWithoutPropertiesLoose(e, _excluded);
156
- var _rest$message = rest.message,
157
- message = _rest$message === void 0 ? '' : _rest$message;
158
- var property = instancePath.replace(/\//g, '.');
159
- var stack = (property + " " + message).trim();
160
- if ('missingProperty' in params) {
161
- property = property ? property + "." + params.missingProperty : params.missingProperty;
162
- var currentProperty = params.missingProperty;
163
- var uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, "" + property.replace(/^\./, ''))).title;
164
- if (uiSchemaTitle) {
165
- message = message.replace(currentProperty, uiSchemaTitle);
166
- } else {
167
- var parentSchemaTitle = get__default["default"](parentSchema, [utils.PROPERTIES_KEY, currentProperty, 'title']);
168
- if (parentSchemaTitle) {
169
- message = message.replace(currentProperty, parentSchemaTitle);
170
- }
171
- }
172
- stack = message;
173
- } else {
174
- var _uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, "" + property.replace(/^\./, ''))).title;
175
- if (_uiSchemaTitle) {
176
- stack = ("'" + _uiSchemaTitle + "' " + message).trim();
177
- } else {
178
- var _parentSchemaTitle = parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.title;
179
- if (_parentSchemaTitle) {
180
- stack = ("'" + _parentSchemaTitle + "' " + message).trim();
181
- }
182
- }
183
- }
184
- // put data in expected format
185
- return {
186
- name: keyword,
187
- property: property,
188
- message: message,
189
- params: params,
190
- stack: stack,
191
- schemaPath: schemaPath
192
- };
193
- });
194
- }
195
245
  /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use
196
246
  * by the playground. Returns the `errors` from the validation
197
247
  *
@@ -201,8 +251,8 @@
201
251
  _proto.rawValidation = function rawValidation(schema, formData) {
202
252
  var compilationError = undefined;
203
253
  var compiledValidator;
204
- if (schema['$id']) {
205
- compiledValidator = this.ajv.getSchema(schema['$id']);
254
+ if (schema[utils.ID_KEY]) {
255
+ compiledValidator = this.ajv.getSchema(schema[utils.ID_KEY]);
206
256
  }
207
257
  try {
208
258
  if (compiledValidator === undefined) {
@@ -239,38 +289,7 @@
239
289
  */;
240
290
  _proto.validateFormData = function validateFormData(formData, schema, customValidate, transformErrors, uiSchema) {
241
291
  var rawErrors = this.rawValidation(schema, formData);
242
- var invalidSchemaError = rawErrors.validationError;
243
- var errors = this.transformRJSFValidationErrors(rawErrors.errors, uiSchema);
244
- if (invalidSchemaError) {
245
- errors = [].concat(errors, [{
246
- stack: invalidSchemaError.message
247
- }]);
248
- }
249
- if (typeof transformErrors === 'function') {
250
- errors = transformErrors(errors, uiSchema);
251
- }
252
- var errorSchema = utils.toErrorSchema(errors);
253
- if (invalidSchemaError) {
254
- errorSchema = _extends({}, errorSchema, {
255
- $schema: {
256
- __errors: [invalidSchemaError.message]
257
- }
258
- });
259
- }
260
- if (typeof customValidate !== 'function') {
261
- return {
262
- errors: errors,
263
- errorSchema: errorSchema
264
- };
265
- }
266
- // Include form data with undefined values, which is required for custom validation.
267
- var newFormData = utils.getDefaultFormState(this, schema, formData, schema, true);
268
- var errorHandler = customValidate(newFormData, utils.createErrorHandler(newFormData), uiSchema);
269
- var userErrorSchema = utils.unwrapErrorHandler(errorHandler);
270
- return utils.validationDataMerge({
271
- errors: errors,
272
- errorSchema: errorSchema
273
- }, userErrorSchema);
292
+ return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);
274
293
  }
275
294
  /** Validates data against a schema, returning true if the data is valid, or
276
295
  * false otherwise. If the schema is invalid, then this function will return
@@ -281,8 +300,8 @@
281
300
  * @param rootSchema - The root schema used to provide $ref resolutions
282
301
  */;
283
302
  _proto.isValid = function isValid(schema, formData, rootSchema) {
284
- var _rootSchema$$id;
285
- var rootSchemaId = (_rootSchema$$id = rootSchema['$id']) != null ? _rootSchema$$id : utils.ROOT_SCHEMA_PREFIX;
303
+ var _rootSchema$ID_KEY;
304
+ var rootSchemaId = (_rootSchema$ID_KEY = rootSchema[utils.ID_KEY]) != null ? _rootSchema$ID_KEY : utils.ROOT_SCHEMA_PREFIX;
286
305
  try {
287
306
  // add the rootSchema ROOT_SCHEMA_PREFIX as id.
288
307
  // then rewrite the schema ref's to point to the rootSchema
@@ -293,8 +312,8 @@
293
312
  }
294
313
  var schemaWithIdRefPrefix = utils.withIdRefPrefix(schema);
295
314
  var compiledValidator;
296
- if (schemaWithIdRefPrefix['$id']) {
297
- compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix['$id']);
315
+ if (schemaWithIdRefPrefix[utils.ID_KEY]) {
316
+ compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[utils.ID_KEY]);
298
317
  }
299
318
  if (compiledValidator === undefined) {
300
319
  compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);
@@ -314,10 +333,12 @@
314
333
  }();
315
334
 
316
335
  /** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if
317
- * provided.
336
+ * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV
337
+ * validation.
318
338
  *
319
339
  * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance
320
340
  * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s
341
+ * @returns - The custom validator implementation resulting from the set of parameters provided
321
342
  */
322
343
  function customizeValidator(options, localizer) {
323
344
  if (options === void 0) {
@@ -326,8 +347,187 @@
326
347
  return new AJV8Validator(options, localizer);
327
348
  }
328
349
 
350
+ /** The function used to compile a schema into an output file in the form that allows it to be used as a precompiled
351
+ * validator. The main reasons for using a precompiled validator is reducing code size, improving validation speed and,
352
+ * most importantly, avoiding dynamic code compilation when prohibited by a browser's Content Security Policy. For more
353
+ * information about AJV code compilation see: https://ajv.js.org/standalone.html
354
+ *
355
+ * @param schema - The schema to be compiled into a set of precompiled validators functions
356
+ * @param output - The name of the file into which the precompiled validator functions will be generated
357
+ * @param [options={}] - The set of `CustomValidatorOptionsType` information used to alter the AJV validator used for
358
+ * compiling the schema. They are the same options that are passed to the `customizeValidator()` function in
359
+ * order to modify the behavior of the regular AJV-based validator.
360
+ */
361
+ function compileSchemaValidators(schema, output, options) {
362
+ if (options === void 0) {
363
+ options = {};
364
+ }
365
+ console.log('parsing the schema');
366
+ var schemaMaps = utils.schemaParser(schema);
367
+ var schemas = Object.values(schemaMaps);
368
+ var _options = options,
369
+ additionalMetaSchemas = _options.additionalMetaSchemas,
370
+ customFormats = _options.customFormats,
371
+ _options$ajvOptionsOv = _options.ajvOptionsOverrides,
372
+ ajvOptionsOverrides = _options$ajvOptionsOv === void 0 ? {} : _options$ajvOptionsOv,
373
+ ajvFormatOptions = _options.ajvFormatOptions,
374
+ AjvClass = _options.AjvClass;
375
+ // Allow users to turn off the `lines: true` feature in their own overrides, but NOT the `source: true`
376
+ var compileOptions = _extends({}, ajvOptionsOverrides, {
377
+ code: _extends({
378
+ lines: true
379
+ }, ajvOptionsOverrides.code, {
380
+ source: true
381
+ }),
382
+ schemas: schemas
383
+ });
384
+ var ajv = createAjvInstance(additionalMetaSchemas, customFormats, compileOptions, ajvFormatOptions, AjvClass);
385
+ var moduleCode = standaloneCode__default["default"](ajv);
386
+ console.log("writing " + output);
387
+ fs__default["default"].writeFileSync(output, moduleCode);
388
+ }
389
+
390
+ /** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the
391
+ * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.
392
+ */
393
+ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
394
+ /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`
395
+ *
396
+ * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function
397
+ * @param rootSchema - The root schema that was used with the `compileSchema()` function
398
+ * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s
399
+ * @throws - Error when the base schema of the precompiled validator does not have a matching validator function
400
+ */
401
+ function AJV8PrecompiledValidator(validateFns, rootSchema, localizer) {
402
+ /** The root schema object used to construct this validator
403
+ *
404
+ * @private
405
+ */
406
+ this.rootSchema = void 0;
407
+ /** The `ValidatorFunctions` map used to construct this validator
408
+ *
409
+ * @private
410
+ */
411
+ this.validateFns = void 0;
412
+ /** The main validator function associated with the base schema in the `precompiledValidator`
413
+ *
414
+ * @private
415
+ */
416
+ this.mainValidator = void 0;
417
+ /** The Localizer function to use for localizing Ajv errors
418
+ *
419
+ * @private
420
+ */
421
+ this.localizer = void 0;
422
+ this.rootSchema = rootSchema;
423
+ this.validateFns = validateFns;
424
+ this.localizer = localizer;
425
+ this.mainValidator = this.getValidator(rootSchema);
426
+ }
427
+ /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator
428
+ * functions.
429
+ *
430
+ * @param schema - The schema for which a precompiled validator function is desired
431
+ * @returns - The precompiled validator function associated with this schema
432
+ */
433
+ var _proto = AJV8PrecompiledValidator.prototype;
434
+ _proto.getValidator = function getValidator(schema) {
435
+ var key = get__default["default"](schema, utils.ID_KEY) || utils.hashForSchema(schema);
436
+ var validator = this.validateFns[key];
437
+ if (!validator) {
438
+ throw new Error("No precompiled validator function was found for the given schema for \"" + key + "\"");
439
+ }
440
+ return validator;
441
+ }
442
+ /** Converts an `errorSchema` into a list of `RJSFValidationErrors`
443
+ *
444
+ * @param errorSchema - The `ErrorSchema` instance to convert
445
+ * @param [fieldPath=[]] - The current field path, defaults to [] if not specified
446
+ * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in
447
+ * the next major release.
448
+ */;
449
+ _proto.toErrorList = function toErrorList(errorSchema, fieldPath) {
450
+ if (fieldPath === void 0) {
451
+ fieldPath = [];
452
+ }
453
+ return utils.toErrorList(errorSchema, fieldPath);
454
+ }
455
+ /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use
456
+ * by the playground. Returns the `errors` from the validation
457
+ *
458
+ * @param schema - The schema against which to validate the form data * @param schema
459
+ * @param formData - The form data to validate
460
+ * @throws - Error when the schema provided does not match the base schema of the precompiled validator
461
+ */;
462
+ _proto.rawValidation = function rawValidation(schema, formData) {
463
+ if (!isEqual__default["default"](schema, this.rootSchema)) {
464
+ throw new Error('The schema associated with the precompiled schema differs from the schema provided for validation');
465
+ }
466
+ this.mainValidator(formData);
467
+ if (typeof this.localizer === 'function') {
468
+ this.localizer(this.mainValidator.errors);
469
+ }
470
+ var errors = this.mainValidator.errors || undefined;
471
+ // Clear errors to prevent persistent errors, see #1104
472
+ this.mainValidator.errors = null;
473
+ return {
474
+ errors: errors
475
+ };
476
+ }
477
+ /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives
478
+ * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also
479
+ * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and
480
+ * transform them in what ever way it chooses.
481
+ *
482
+ * @param formData - The form data to validate
483
+ * @param schema - The schema against which to validate the form data
484
+ * @param [customValidate] - An optional function that is used to perform custom validation
485
+ * @param [transformErrors] - An optional function that is used to transform errors after AJV validation
486
+ * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
487
+ */;
488
+ _proto.validateFormData = function validateFormData(formData, schema, customValidate, transformErrors, uiSchema) {
489
+ var rawErrors = this.rawValidation(schema, formData);
490
+ return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);
491
+ }
492
+ /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is
493
+ * invalid, then this function will return false.
494
+ *
495
+ * @param schema - The schema against which to validate the form data
496
+ * @param formData - The form data to validate
497
+ * @param rootSchema - The root schema used to provide $ref resolutions
498
+ * @returns - true if the formData validates against the schema, false otherwise
499
+ * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there
500
+ * isn't a precompiled validator function associated with the schema
501
+ */;
502
+ _proto.isValid = function isValid(schema, formData, rootSchema) {
503
+ if (!isEqual__default["default"](rootSchema, this.rootSchema)) {
504
+ throw new Error('The schema associated with the precompiled validator differs from the rootSchema provided for validation');
505
+ }
506
+ var validator = this.getValidator(schema);
507
+ return validator(formData);
508
+ };
509
+ return AJV8PrecompiledValidator;
510
+ }();
511
+
512
+ /** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`
513
+ * is provided, it is used to translate the messages generated by the underlying AJV validation.
514
+ *
515
+ * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via
516
+ * the `compileSchemaValidators()` function.
517
+ *
518
+ * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function
519
+ * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function
520
+ * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s
521
+ * @returns - The precompiled validator implementation resulting from the set of parameters provided
522
+ */
523
+ function createPrecompiledValidator(validateFns, rootSchema, localizer) {
524
+ return new AJV8PrecompiledValidator(validateFns, rootSchema, localizer);
525
+ }
526
+
329
527
  var index = /*#__PURE__*/customizeValidator();
330
528
 
529
+ exports.compileSchemaValidators = compileSchemaValidators;
530
+ exports.createPrecompiledValidator = createPrecompiledValidator;
331
531
  exports.customizeValidator = customizeValidator;
332
532
  exports["default"] = index;
333
533
 
@@ -1 +1 @@
1
- {"version":3,"file":"validator-ajv8.umd.development.js","sources":["../src/createAjvInstance.ts","../src/validator.ts","../src/customizeValidator.ts","../src/index.ts"],"sourcesContent":["import Ajv, { Options } from 'ajv';\nimport addFormats, { FormatsPluginOptions } from 'ajv-formats';\nimport isObject from 'lodash/isObject';\n\nimport { CustomValidatorOptionsType } from './types';\nimport { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG } from '@rjsf/utils';\n\nexport const AJV_CONFIG: Options = {\n allErrors: true,\n multipleOfPrecision: 8,\n strict: false,\n verbose: true,\n} as const;\nexport const COLOR_FORMAT_REGEX =\n /^(#?([0-9A-Fa-f]{3}){1,2}\\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\\(\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*\\))|(rgb\\(\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*\\)))$/;\nexport const DATA_URL_FORMAT_REGEX = /^data:([a-z]+\\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;\n\n/** Creates an Ajv version 8 implementation object with standard support for the 'color` and `data-url` custom formats.\n * If `additionalMetaSchemas` are provided then the Ajv instance is modified to add each of the meta schemas in the\n * list. If `customFormats` are provided then those additional formats are added to the list of supported formats. If\n * `ajvOptionsOverrides` are provided then they are spread on top of the default `AJV_CONFIG` options when constructing\n * the `Ajv` instance. With Ajv v8, the JSON Schema formats are not provided by default, but can be plugged in. By\n * default, all formats from the `ajv-formats` library are added. To disable this capability, set the `ajvFormatOptions`\n * parameter to `false`. Additionally, you can configure the `ajv-formats` by providing a custom set of\n * [format options](https://github.com/ajv-validator/ajv-formats) to the `ajvFormatOptions` parameter.\n *\n * @param [additionalMetaSchemas] - The list of additional meta schemas that the validator can access\n * @param [customFormats] - The set of additional custom formats that the validator will support\n * @param [ajvOptionsOverrides={}] - The set of validator config override options\n * @param [ajvFormatOptions] - The `ajv-format` options to use when adding formats to `ajv`; pass `false` to disable it\n * @param [AjvClass] - The `Ajv` class to use when creating the validator instance\n */\nexport default function createAjvInstance(\n additionalMetaSchemas?: CustomValidatorOptionsType['additionalMetaSchemas'],\n customFormats?: CustomValidatorOptionsType['customFormats'],\n ajvOptionsOverrides: CustomValidatorOptionsType['ajvOptionsOverrides'] = {},\n ajvFormatOptions?: FormatsPluginOptions | false,\n AjvClass: typeof Ajv = Ajv\n) {\n const ajv = new AjvClass({ ...AJV_CONFIG, ...ajvOptionsOverrides });\n if (ajvFormatOptions) {\n addFormats(ajv, ajvFormatOptions);\n } else if (ajvFormatOptions !== false) {\n addFormats(ajv);\n }\n\n // add custom formats\n ajv.addFormat('data-url', DATA_URL_FORMAT_REGEX);\n ajv.addFormat('color', COLOR_FORMAT_REGEX);\n\n // Add RJSF-specific additional properties keywords so Ajv doesn't report errors if strict is enabled.\n ajv.addKeyword(ADDITIONAL_PROPERTY_FLAG);\n ajv.addKeyword(RJSF_ADDITONAL_PROPERTIES_FLAG);\n\n // add more schemas to validate against\n if (Array.isArray(additionalMetaSchemas)) {\n ajv.addMetaSchema(additionalMetaSchemas);\n }\n\n // add more custom formats to validate against\n if (isObject(customFormats)) {\n Object.keys(customFormats).forEach((formatName) => {\n ajv.addFormat(formatName, customFormats[formatName]);\n });\n }\n\n return ajv;\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n ValidationData,\n validationDataMerge,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n * @protected\n */\n protected transformRJSFValidationErrors(\n errors: ErrorObject[] = [],\n uiSchema?: UiSchema<T, S, F>\n ): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: RJSFSchema, formData?: T): { errors?: Result[]; validationError?: Error } {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema['$id']) {\n compiledValidator = this.ajv.getSchema(schema['$id']);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = this.transformRJSFValidationErrors(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(this, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema['$id'] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix['$id']) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix['$id']);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import customizeValidator from './customizeValidator';\n\nexport { customizeValidator };\nexport * from './types';\n\nexport default customizeValidator();\n"],"names":["AJV_CONFIG","allErrors","multipleOfPrecision","strict","verbose","COLOR_FORMAT_REGEX","DATA_URL_FORMAT_REGEX","createAjvInstance","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","ajv","_extends","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName","AJV8Validator","options","localizer","_proto","prototype","toErrorList","errorSchema","fieldPath","transformRJSFValidationErrors","errors","uiSchema","map","e","instancePath","keyword","params","schemaPath","parentSchema","rest","_objectWithoutPropertiesLoose","_excluded","_rest$message","message","property","replace","stack","trim","missingProperty","currentProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","rawValidation","schema","formData","compilationError","undefined","compiledValidator","getSchema","compile","err","validationError","validateFormData","customValidate","transformErrors","rawErrors","invalidSchemaError","concat","toErrorSchema","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","isValid","rootSchema","_rootSchema$$id","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","result","console","warn","removeSchema","customizeValidator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOO,IAAMA,UAAU,GAAY;EACjCC,EAAAA,SAAS,EAAE,IAAI;EACfC,EAAAA,mBAAmB,EAAE,CAAC;EACtBC,EAAAA,MAAM,EAAE,KAAK;EACbC,EAAAA,OAAO,EAAE,IA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OAAOgC,MAAiB,CAAA;OACzB,CAAC,OAAO1D,CAAC,EAAE;EACV2D,MAAAA,OAAO,CAACC,IAAI,CAAC,qCAAqC,EAAE5D,CAAC,CAAC,CAAA;EACtD,MAAA,OAAO,KAAK,CAAA;EACb,KAAA,SAAS;EACR;EACA;EACA,MAAA,IAAI,CAAC3B,GAAG,CAACwF,YAAY,CAACR,YAAY,CAAC,CAAA;EACpC,KAAA;KACF,CAAA;EAAA,EAAA,OAAAjE,aAAA,CAAA;EAAA,CAAA,EAAA;;ECvPH;;;;;EAKG;EACqB,SAAA0E,kBAAkBA,CAIxCzE,OAAsC,EAAIC,SAAqB,EAAA;EAAA,EAAA,IAA/DD,OAAsC,KAAA,KAAA,CAAA,EAAA;MAAtCA,OAAsC,GAAA,EAAE,CAAA;EAAA,GAAA;EACxC,EAAA,OAAO,IAAID,aAAa,CAAUC,OAAO,EAAEC,SAAS,CAAC,CAAA;EACvD;;ACZA,cAAA,aAAewE,kBAAkB,EAAE;;;;;;;;;;;"}
1
+ {"version":3,"file":"validator-ajv8.umd.development.js","sources":["../src/createAjvInstance.ts","../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/compileSchemaValidators.ts","../src/precompiledValidator.ts","../src/createPrecompiledValidator.ts","../src/index.ts"],"sourcesContent":["import Ajv, { Options } from 'ajv';\nimport addFormats, { FormatsPluginOptions } from 'ajv-formats';\nimport isObject from 'lodash/isObject';\n\nimport { CustomValidatorOptionsType } from './types';\nimport { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG } from '@rjsf/utils';\n\nexport const AJV_CONFIG: Options = {\n allErrors: true,\n multipleOfPrecision: 8,\n strict: false,\n verbose: true,\n} as const;\nexport const COLOR_FORMAT_REGEX =\n /^(#?([0-9A-Fa-f]{3}){1,2}\\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\\(\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*\\))|(rgb\\(\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*\\)))$/;\nexport const DATA_URL_FORMAT_REGEX = /^data:([a-z]+\\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;\n\n/** Creates an Ajv version 8 implementation object with standard support for the 'color` and `data-url` custom formats.\n * If `additionalMetaSchemas` are provided then the Ajv instance is modified to add each of the meta schemas in the\n * list. If `customFormats` are provided then those additional formats are added to the list of supported formats. If\n * `ajvOptionsOverrides` are provided then they are spread on top of the default `AJV_CONFIG` options when constructing\n * the `Ajv` instance. With Ajv v8, the JSON Schema formats are not provided by default, but can be plugged in. By\n * default, all formats from the `ajv-formats` library are added. To disable this capability, set the `ajvFormatOptions`\n * parameter to `false`. Additionally, you can configure the `ajv-formats` by providing a custom set of\n * [format options](https://github.com/ajv-validator/ajv-formats) to the `ajvFormatOptions` parameter.\n *\n * @param [additionalMetaSchemas] - The list of additional meta schemas that the validator can access\n * @param [customFormats] - The set of additional custom formats that the validator will support\n * @param [ajvOptionsOverrides={}] - The set of validator config override options\n * @param [ajvFormatOptions] - The `ajv-format` options to use when adding formats to `ajv`; pass `false` to disable it\n * @param [AjvClass] - The `Ajv` class to use when creating the validator instance\n */\nexport default function createAjvInstance(\n additionalMetaSchemas?: CustomValidatorOptionsType['additionalMetaSchemas'],\n customFormats?: CustomValidatorOptionsType['customFormats'],\n ajvOptionsOverrides: CustomValidatorOptionsType['ajvOptionsOverrides'] = {},\n ajvFormatOptions?: FormatsPluginOptions | false,\n AjvClass: typeof Ajv = Ajv\n) {\n const ajv = new AjvClass({ ...AJV_CONFIG, ...ajvOptionsOverrides });\n if (ajvFormatOptions) {\n addFormats(ajv, ajvFormatOptions);\n } else if (ajvFormatOptions !== false) {\n addFormats(ajv);\n }\n\n // add custom formats\n ajv.addFormat('data-url', DATA_URL_FORMAT_REGEX);\n ajv.addFormat('color', COLOR_FORMAT_REGEX);\n\n // Add RJSF-specific additional properties keywords so Ajv doesn't report errors if strict is enabled.\n ajv.addKeyword(ADDITIONAL_PROPERTY_FLAG);\n ajv.addKeyword(RJSF_ADDITONAL_PROPERTIES_FLAG);\n\n // add more schemas to validate against\n if (Array.isArray(additionalMetaSchemas)) {\n ajv.addMetaSchema(additionalMetaSchemas);\n }\n\n // add more custom formats to validate against\n if (isObject(customFormats)) {\n Object.keys(customFormats).forEach((formatName) => {\n ajv.addFormat(formatName, customFormats[formatName]);\n });\n }\n\n return ajv;\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import fs from 'fs';\nimport standaloneCode from 'ajv/dist/standalone';\nimport { RJSFSchema, StrictRJSFSchema, schemaParser } from '@rjsf/utils';\n\nimport createAjvInstance from './createAjvInstance';\nimport { CustomValidatorOptionsType } from './types';\n\n/** The function used to compile a schema into an output file in the form that allows it to be used as a precompiled\n * validator. The main reasons for using a precompiled validator is reducing code size, improving validation speed and,\n * most importantly, avoiding dynamic code compilation when prohibited by a browser's Content Security Policy. For more\n * information about AJV code compilation see: https://ajv.js.org/standalone.html\n *\n * @param schema - The schema to be compiled into a set of precompiled validators functions\n * @param output - The name of the file into which the precompiled validator functions will be generated\n * @param [options={}] - The set of `CustomValidatorOptionsType` information used to alter the AJV validator used for\n * compiling the schema. They are the same options that are passed to the `customizeValidator()` function in\n * order to modify the behavior of the regular AJV-based validator.\n */\nexport default function compileSchemaValidators<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n output: string,\n options: CustomValidatorOptionsType = {}\n) {\n console.log('parsing the schema');\n const schemaMaps = schemaParser(schema);\n const schemas = Object.values(schemaMaps);\n\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides = {}, ajvFormatOptions, AjvClass } = options;\n // Allow users to turn off the `lines: true` feature in their own overrides, but NOT the `source: true`\n const compileOptions = {\n ...ajvOptionsOverrides,\n code: { lines: true, ...ajvOptionsOverrides.code, source: true },\n schemas,\n };\n const ajv = createAjvInstance(additionalMetaSchemas, customFormats, compileOptions, ajvFormatOptions, AjvClass);\n\n const moduleCode = standaloneCode(ajv);\n console.log(`writing ${output}`);\n fs.writeFileSync(output, moduleCode);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions<T>;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction<T>;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions<T>, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions<T>, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n","import customizeValidator from './customizeValidator';\nimport compileSchemaValidators from './compileSchemaValidators';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, compileSchemaValidators, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n"],"names":["AJV_CONFIG","allErrors","multipleOfPrecision","strict","verbose","COLOR_FORMAT_REGEX","DATA_URL_FORMAT_REGEX","createAjvInstance","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","ajv","_extends","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName","transformRJSFValidationErrors","errors","uiSchema","map","e","instancePath","keyword","params","schemaPath","parentSchema","rest","_objectWithoutPropertiesLoose","_excluded","_rest$message","message","property","replace","stack","trim","missingProperty","currentProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","invalidSchemaError","validationError","concat","errorSchema","toErrorSchema","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","_proto","prototype","toErrorList","fieldPath","rawValidation","compilationError","undefined","compiledValidator","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","result","console","warn","removeSchema","customizeValidator","compileSchemaValidators","output","log","schemaMaps","schemaParser","schemas","values","_options","_options$ajvOptionsOv","compileOptions","code","lines","source","moduleCode","standaloneCode","fs","writeFileSync","AJV8PrecompiledValidator","validateFns","mainValidator","getValidator","key","hashForS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