@rjsf/validator-ajv8 5.5.2 → 5.6.2

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.
@@ -2,20 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var toPath = require('lodash/toPath');
6
- var isPlainObject = require('lodash/isPlainObject');
7
- var clone = require('lodash/clone');
8
- var utils = require('@rjsf/utils');
9
5
  var get = require('lodash/get');
6
+ var utils = require('@rjsf/utils');
10
7
  var Ajv = require('ajv');
11
8
  var addFormats = require('ajv-formats');
12
9
  var isObject = require('lodash/isObject');
13
10
 
14
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
12
 
16
- var toPath__default = /*#__PURE__*/_interopDefaultLegacy(toPath);
17
- var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
18
- var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
19
13
  var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
20
14
  var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
21
15
  var addFormats__default = /*#__PURE__*/_interopDefaultLegacy(addFormats);
@@ -104,7 +98,6 @@ function createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverr
104
98
  }
105
99
 
106
100
  var _excluded = ["instancePath", "keyword", "params", "schemaPath", "parentSchema"];
107
- var ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';
108
101
  /** `ValidatorType` implementation that uses the AJV 8 validation mechanism.
109
102
  */
110
103
  var AJV8Validator = /*#__PURE__*/function () {
@@ -132,135 +125,25 @@ var AJV8Validator = /*#__PURE__*/function () {
132
125
  this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);
133
126
  this.localizer = localizer;
134
127
  }
135
- /** Transforms a ajv validation errors list:
136
- * [
137
- * {property: '.level1.level2[2].level3', message: 'err a'},
138
- * {property: '.level1.level2[2].level3', message: 'err b'},
139
- * {property: '.level1.level2[4].level3', message: 'err b'},
140
- * ]
141
- * Into an error tree:
142
- * {
143
- * level1: {
144
- * level2: {
145
- * 2: {level3: {errors: ['err a', 'err b']}},
146
- * 4: {level3: {errors: ['err b']}},
147
- * }
148
- * }
149
- * };
150
- *
151
- * @param errors - The list of RJSFValidationError objects
152
- * @private
153
- */
154
- var _proto = AJV8Validator.prototype;
155
- _proto.toErrorSchema = function toErrorSchema(errors) {
156
- var builder = new utils.ErrorSchemaBuilder();
157
- if (errors.length) {
158
- errors.forEach(function (error) {
159
- var property = error.property,
160
- message = error.message;
161
- var path = toPath__default["default"](property);
162
- // If the property is at the root (.level1) then toPath creates
163
- // an empty array element at the first index. Remove it.
164
- if (path.length > 0 && path[0] === '') {
165
- path.splice(0, 1);
166
- }
167
- if (message) {
168
- builder.addErrors(message, path);
169
- }
170
- });
171
- }
172
- return builder.ErrorSchema;
173
- }
174
128
  /** Converts an `errorSchema` into a list of `RJSFValidationErrors`
175
129
  *
176
130
  * @param errorSchema - The `ErrorSchema` instance to convert
177
131
  * @param [fieldPath=[]] - The current field path, defaults to [] if not specified
178
- */;
132
+ * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in
133
+ * the next major release.
134
+ */
135
+ var _proto = AJV8Validator.prototype;
179
136
  _proto.toErrorList = function toErrorList(errorSchema, fieldPath) {
180
- var _this = this;
181
137
  if (fieldPath === void 0) {
182
138
  fieldPath = [];
183
139
  }
184
- if (!errorSchema) {
185
- return [];
186
- }
187
- var errorList = [];
188
- if (utils.ERRORS_KEY in errorSchema) {
189
- errorList = errorList.concat(errorSchema[utils.ERRORS_KEY].map(function (message) {
190
- var property = "." + fieldPath.join('.');
191
- return {
192
- property: property,
193
- message: message,
194
- stack: property + " " + message
195
- };
196
- }));
197
- }
198
- return Object.keys(errorSchema).reduce(function (acc, key) {
199
- if (key !== utils.ERRORS_KEY) {
200
- var childSchema = errorSchema[key];
201
- if (isPlainObject__default["default"](childSchema)) {
202
- acc = acc.concat(_this.toErrorList(childSchema, [].concat(fieldPath, [key])));
203
- }
204
- }
205
- return acc;
206
- }, errorList);
207
- }
208
- /** Given a `formData` object, recursively creates a `FormValidation` error handling structure around it
209
- *
210
- * @param formData - The form data around which the error handler is created
211
- * @private
212
- */;
213
- _proto.createErrorHandler = function createErrorHandler(formData) {
214
- var _this2 = this;
215
- var handler = {
216
- // We store the list of errors for this node in a property named __errors
217
- // to avoid name collision with a possible sub schema field named
218
- // 'errors' (see `utils.toErrorSchema`).
219
- __errors: [],
220
- addError: function addError(message) {
221
- this.__errors.push(message);
222
- }
223
- };
224
- if (Array.isArray(formData)) {
225
- return formData.reduce(function (acc, value, key) {
226
- var _extends2;
227
- return _extends({}, acc, (_extends2 = {}, _extends2[key] = _this2.createErrorHandler(value), _extends2));
228
- }, handler);
229
- }
230
- if (isPlainObject__default["default"](formData)) {
231
- var formObject = formData;
232
- return Object.keys(formObject).reduce(function (acc, key) {
233
- var _extends3;
234
- return _extends({}, acc, (_extends3 = {}, _extends3[key] = _this2.createErrorHandler(formObject[key]), _extends3));
235
- }, handler);
236
- }
237
- return handler;
238
- }
239
- /** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError` functions from it
240
- *
241
- * @param errorHandler - The `FormValidation` error handling structure
242
- * @private
243
- */;
244
- _proto.unwrapErrorHandler = function unwrapErrorHandler(errorHandler) {
245
- var _this3 = this;
246
- return Object.keys(errorHandler).reduce(function (acc, key) {
247
- if (key === 'addError') {
248
- return acc;
249
- } else {
250
- var _extends5;
251
- var childSchema = errorHandler[key];
252
- if (isPlainObject__default["default"](childSchema)) {
253
- var _extends4;
254
- return _extends({}, acc, (_extends4 = {}, _extends4[key] = _this3.unwrapErrorHandler(childSchema), _extends4));
255
- }
256
- return _extends({}, acc, (_extends5 = {}, _extends5[key] = childSchema, _extends5));
257
- }
258
- }, {});
140
+ return utils.toErrorList(errorSchema, fieldPath);
259
141
  }
260
142
  /** Transforming the error output from ajv to format used by @rjsf/utils.
261
143
  * At some point, components should be updated to support ajv.
262
144
  *
263
145
  * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`
146
+ * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
264
147
  * @protected
265
148
  */;
266
149
  _proto.transformRJSFValidationErrors = function transformRJSFValidationErrors(errors, uiSchema) {
@@ -370,7 +253,7 @@ var AJV8Validator = /*#__PURE__*/function () {
370
253
  if (typeof transformErrors === 'function') {
371
254
  errors = transformErrors(errors, uiSchema);
372
255
  }
373
- var errorSchema = this.toErrorSchema(errors);
256
+ var errorSchema = utils.toErrorSchema(errors);
374
257
  if (invalidSchemaError) {
375
258
  errorSchema = _extends({}, errorSchema, {
376
259
  $schema: {
@@ -386,43 +269,13 @@ var AJV8Validator = /*#__PURE__*/function () {
386
269
  }
387
270
  // Include form data with undefined values, which is required for custom validation.
388
271
  var newFormData = utils.getDefaultFormState(this, schema, formData, schema, true);
389
- var errorHandler = customValidate(newFormData, this.createErrorHandler(newFormData), uiSchema);
390
- var userErrorSchema = this.unwrapErrorHandler(errorHandler);
391
- return utils.mergeValidationData(this, {
272
+ var errorHandler = customValidate(newFormData, utils.createErrorHandler(newFormData), uiSchema);
273
+ var userErrorSchema = utils.unwrapErrorHandler(errorHandler);
274
+ return utils.validationDataMerge({
392
275
  errors: errors,
393
276
  errorSchema: errorSchema
394
277
  }, userErrorSchema);
395
278
  }
396
- /** Takes a `node` object and transforms any contained `$ref` node variables with a prefix, recursively calling
397
- * `withIdRefPrefix` for any other elements.
398
- *
399
- * @param node - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it
400
- * @private
401
- */;
402
- _proto.withIdRefPrefixObject = function withIdRefPrefixObject(node) {
403
- for (var key in node) {
404
- var realObj = node;
405
- var value = realObj[key];
406
- if (key === utils.REF_KEY && typeof value === 'string' && value.startsWith('#')) {
407
- realObj[key] = ROOT_SCHEMA_PREFIX + value;
408
- } else {
409
- realObj[key] = this.withIdRefPrefix(value);
410
- }
411
- }
412
- return node;
413
- }
414
- /** Takes a `node` object list and transforms any contained `$ref` node variables with a prefix, recursively calling
415
- * `withIdRefPrefix` for any other elements.
416
- *
417
- * @param node - The list of object nodes to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it
418
- * @private
419
- */;
420
- _proto.withIdRefPrefixArray = function withIdRefPrefixArray(node) {
421
- for (var i = 0; i < node.length; i++) {
422
- node[i] = this.withIdRefPrefix(node[i]);
423
- }
424
- return node;
425
- }
426
279
  /** Validates data against a schema, returning true if the data is valid, or
427
280
  * false otherwise. If the schema is invalid, then this function will return
428
281
  * false.
@@ -433,7 +286,7 @@ var AJV8Validator = /*#__PURE__*/function () {
433
286
  */;
434
287
  _proto.isValid = function isValid(schema, formData, rootSchema) {
435
288
  var _rootSchema$$id;
436
- var rootSchemaId = (_rootSchema$$id = rootSchema['$id']) != null ? _rootSchema$$id : ROOT_SCHEMA_PREFIX;
289
+ var rootSchemaId = (_rootSchema$$id = rootSchema['$id']) != null ? _rootSchema$$id : utils.ROOT_SCHEMA_PREFIX;
437
290
  try {
438
291
  // add the rootSchema ROOT_SCHEMA_PREFIX as id.
439
292
  // then rewrite the schema ref's to point to the rootSchema
@@ -442,7 +295,7 @@ var AJV8Validator = /*#__PURE__*/function () {
442
295
  if (this.ajv.getSchema(rootSchemaId) === undefined) {
443
296
  this.ajv.addSchema(rootSchema, rootSchemaId);
444
297
  }
445
- var schemaWithIdRefPrefix = this.withIdRefPrefix(schema);
298
+ var schemaWithIdRefPrefix = utils.withIdRefPrefix(schema);
446
299
  var compiledValidator;
447
300
  if (schemaWithIdRefPrefix['$id']) {
448
301
  compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix['$id']);
@@ -460,21 +313,6 @@ var AJV8Validator = /*#__PURE__*/function () {
460
313
  // make sure we remove the rootSchema from the global ajv instance
461
314
  this.ajv.removeSchema(rootSchemaId);
462
315
  }
463
- }
464
- /** Recursively prefixes all $ref's in a schema with `ROOT_SCHEMA_PREFIX`
465
- * This is used in isValid to make references to the rootSchema
466
- *
467
- * @param schemaNode - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it
468
- * @protected
469
- */;
470
- _proto.withIdRefPrefix = function withIdRefPrefix(schemaNode) {
471
- if (Array.isArray(schemaNode)) {
472
- return this.withIdRefPrefixArray([].concat(schemaNode));
473
- }
474
- if (isPlainObject__default["default"](schemaNode)) {
475
- return this.withIdRefPrefixObject(clone__default["default"](schemaNode));
476
- }
477
- return schemaNode;
478
316
  };
479
317
  return AJV8Validator;
480
318
  }();
@@ -1 +1 @@
1
- {"version":3,"file":"validator-ajv8.cjs.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 toPath from 'lodash/toPath';\nimport isPlainObject from 'lodash/isPlainObject';\nimport clone from 'lodash/clone';\nimport {\n CustomValidator,\n ERRORS_KEY,\n ErrorSchema,\n ErrorSchemaBuilder,\n ErrorTransformer,\n FieldValidation,\n FormContextType,\n FormValidation,\n GenericObjectType,\n getDefaultFormState,\n mergeValidationData,\n REF_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n UiSchema,\n ValidationData,\n ValidatorType,\n PROPERTIES_KEY,\n getUiOptions,\n} from '@rjsf/utils';\nimport get from 'lodash/get';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\n\nconst ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';\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 /** Transforms a ajv validation errors list:\n * [\n * {property: '.level1.level2[2].level3', message: 'err a'},\n * {property: '.level1.level2[2].level3', message: 'err b'},\n * {property: '.level1.level2[4].level3', message: 'err b'},\n * ]\n * Into an error tree:\n * {\n * level1: {\n * level2: {\n * 2: {level3: {errors: ['err a', 'err b']}},\n * 4: {level3: {errors: ['err b']}},\n * }\n * }\n * };\n *\n * @param errors - The list of RJSFValidationError objects\n * @private\n */\n private toErrorSchema(errors: RJSFValidationError[]): ErrorSchema<T> {\n const builder = new ErrorSchemaBuilder<T>();\n if (errors.length) {\n errors.forEach((error) => {\n const { property, message } = error;\n const path = toPath(property);\n\n // If the property is at the root (.level1) then toPath creates\n // an empty array element at the first index. Remove it.\n if (path.length > 0 && path[0] === '') {\n path.splice(0, 1);\n }\n if (message) {\n builder.addErrors(message, path);\n }\n });\n }\n return builder.ErrorSchema;\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 */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n if (!errorSchema) {\n return [];\n }\n let errorList: RJSFValidationError[] = [];\n if (ERRORS_KEY in errorSchema) {\n errorList = errorList.concat(\n errorSchema[ERRORS_KEY]!.map((message: string) => {\n const property = `.${fieldPath.join('.')}`;\n return {\n property,\n message,\n stack: `${property} ${message}`,\n };\n })\n );\n }\n return Object.keys(errorSchema).reduce((acc, key) => {\n if (key !== ERRORS_KEY) {\n const childSchema = (errorSchema as GenericObjectType)[key];\n if (isPlainObject(childSchema)) {\n acc = acc.concat(this.toErrorList(childSchema, [...fieldPath, key]));\n }\n }\n return acc;\n }, errorList);\n }\n\n /** Given a `formData` object, recursively creates a `FormValidation` error handling structure around it\n *\n * @param formData - The form data around which the error handler is created\n * @private\n */\n private createErrorHandler(formData: T): FormValidation<T> {\n const handler: FieldValidation = {\n // We store the list of errors for this node in a property named __errors\n // to avoid name collision with a possible sub schema field named\n // 'errors' (see `utils.toErrorSchema`).\n __errors: [],\n addError(message: string) {\n this.__errors!.push(message);\n },\n };\n if (Array.isArray(formData)) {\n return formData.reduce((acc, value, key) => {\n return { ...acc, [key]: this.createErrorHandler(value) };\n }, handler);\n }\n if (isPlainObject(formData)) {\n const formObject: GenericObjectType = formData as GenericObjectType;\n return Object.keys(formObject).reduce((acc, key) => {\n return { ...acc, [key]: this.createErrorHandler(formObject[key]) };\n }, handler as FormValidation<T>);\n }\n return handler as FormValidation<T>;\n }\n\n /** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError` functions from it\n *\n * @param errorHandler - The `FormValidation` error handling structure\n * @private\n */\n private unwrapErrorHandler(errorHandler: FormValidation<T>): ErrorSchema<T> {\n return Object.keys(errorHandler).reduce((acc, key) => {\n if (key === 'addError') {\n return acc;\n } else {\n const childSchema = (errorHandler as GenericObjectType)[key];\n if (isPlainObject(childSchema)) {\n return {\n ...acc,\n [key]: this.unwrapErrorHandler(childSchema),\n };\n }\n return { ...acc, [key]: childSchema };\n }\n }, {} as ErrorSchema<T>);\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 * @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(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 = this.toErrorSchema(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, this.createErrorHandler(newFormData), uiSchema);\n const userErrorSchema = this.unwrapErrorHandler(errorHandler);\n return mergeValidationData<T, S, F>(this, { errors, errorSchema }, userErrorSchema);\n }\n\n /** Takes a `node` object and transforms any contained `$ref` node variables with a prefix, recursively calling\n * `withIdRefPrefix` for any other elements.\n *\n * @param node - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n * @private\n */\n private withIdRefPrefixObject(node: S) {\n for (const key in node) {\n const realObj: GenericObjectType = node;\n const value = realObj[key];\n if (key === REF_KEY && typeof value === 'string' && value.startsWith('#')) {\n realObj[key] = ROOT_SCHEMA_PREFIX + value;\n } else {\n realObj[key] = this.withIdRefPrefix(value);\n }\n }\n return node;\n }\n\n /** Takes a `node` object list and transforms any contained `$ref` node variables with a prefix, recursively calling\n * `withIdRefPrefix` for any other elements.\n *\n * @param node - The list of object nodes to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n * @private\n */\n private withIdRefPrefixArray(node: S[]): S[] {\n for (let i = 0; i < node.length; i++) {\n node[i] = this.withIdRefPrefix(node[i]) as S;\n }\n return node;\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 = this.withIdRefPrefix(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 /** Recursively prefixes all $ref's in a schema with `ROOT_SCHEMA_PREFIX`\n * This is used in isValid to make references to the rootSchema\n *\n * @param schemaNode - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n * @protected\n */\n protected withIdRefPrefix(schemaNode: S | S[]): S | S[] {\n if (Array.isArray(schemaNode)) {\n return this.withIdRefPrefixArray([...schemaNode]);\n }\n if (isPlainObject(schemaNode)) {\n return this.withIdRefPrefixObject(clone<S>(schemaNode));\n }\n return schemaNode;\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","ROOT_SCHEMA_PREFIX","AJV8Validator","options","localizer","_proto","prototype","toErrorSchema","errors","builder","ErrorSchemaBuilder","length","error","property","message","path","toPath","splice","addErrors","ErrorSchema","toErrorList","errorSchema","fieldPath","_this","errorList","ERRORS_KEY","concat","map","join","stack","reduce","acc","key","childSchema","isPlainObject","createErrorHandler","formData","_this2","handler","__errors","addError","push","value","_extends2","formObject","_extends3","unwrapErrorHandler","errorHandler","_this3","_extends5","_extends4","transformRJSFValidationErrors","uiSchema","e","instancePath","keyword","params","schemaPath","parentSchema","rest","_objectWithoutPropertiesLoose","_excluded","_rest$message","replace","trim","missingProperty","currentProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","rawValidation","schema","compilationError","undefined","compiledValidator","getSchema","compile","err","validationError","validateFormData","customValidate","transformErrors","rawErrors","invalidSchemaError","$schema","newFormData","getDefaultFormState","userErrorSchema","mergeValidationData","withIdRefPrefixObject","node","realObj","REF_KEY","startsWith","withIdRefPrefix","withIdRefPrefixArray","i","isValid","rootSchema","_rootSchema$$id","rootSchemaId","addSchema","schemaWithIdRefPrefix","result","console","warn","removeSchema","schemaNode","clone","customizeValidator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,IAAMA,UAAU,GAAY;AACjCC,EAAAA,SAAS,EAAE,IAAI;AACfC,EAAAA,mBAAmB,EAAE,CAAC;AACtBC,EAAAA,MAAM,EAAE,KAAK;AACbC,EAAAA,OAAO,EAAE,IAAA;CACD,CAAA;AACH,IAAMC,kBAAkB,GAC7B,4YAA4Y,CAAA;AACvY,IAAMC,qBAAqB,GAAG,2DAA2D,CAAA;AAEhG;;;;;;;;;;;;;;AAcG;AACqB,SAAAC,iBAAiBA,CACvCC,qBAA2E,EAC3EC,aAA2D,EAC3DC,qBACAC,gBAA+C,EAC/CC,UAA0B;AAAA,EAAA,IAF1BF;IAAAA,sBAAyE,EAAE,CAAA;AAAA,GAAA;AAAA,EAAA,IAE3EE;AAAAA,IAAAA,WAAuBC,uBAAG,CAAA;AAAA,GAAA;EAE1B,IAAMC,GAAG,GAAG,IAAIF,QAAQ,CAAAG,QAAA,CAAMf,EAAAA,EAAAA,UAAU,EAAKU,mBAAmB,CAAG,CAAA,CAAA;AACnE,EAAA,IAAIC,gBAAgB,EAAE;AACpBK,IAAAA,8BAAU,CAACF,GAAG,EAAEH,gBAAgB,CAAC,CAAA;AAClC,GAAA,MAAM,IAAIA,gBAAgB,KAAK,KAAK,EAAE;IACrCK,8BAAU,CAACF,GAAG,CAAC,CAAA;AAChB,GAAA;AAED;AACAA,EAAAA,GAAG,CAACG,SAAS,CA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AAU,CAAC,EAAE;AAC7B,MAAA,OAAO,IAAI,CAACZ,oBAAoB,IAAAzE,MAAA,CAAKqF,UAAU,CAAE,CAAA,CAAA;AAClD,KAAA;AACD,IAAA,IAAI7E,iCAAa,CAAC6E,UAAU,CAAC,EAAE;MAC7B,OAAO,IAAI,CAAClB,qBAAqB,CAACmB,yBAAK,CAAID,UAAU,CAAC,CAAC,CAAA;AACxD,KAAA;AACD,IAAA,OAAOA,UAAU,CAAA;GAClB,CAAA;AAAA,EAAA,OAAA7G,aAAA,CAAA;AAAA,CAAA,EAAA;;AC3ZH;;;;;AAKG;AACqB,SAAA+G,kBAAkBA,CAIxC9G,OAAsC,EAAIC,SAAqB,EAAA;AAAA,EAAA,IAA/DD,OAAsC,KAAA,KAAA,CAAA,EAAA;IAAtCA,OAAsC,GAAA,EAAE,CAAA;AAAA,GAAA;AACxC,EAAA,OAAO,IAAID,aAAa,CAAUC,OAAO,EAAEC,SAAS,CAAC,CAAA;AACvD;;ACZA,YAAA,aAAe6G,kBAAkB,EAAE;;;;;"}
1
+ {"version":3,"file":"validator-ajv8.cjs.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,IAAMA,UAAU,GAAY;AACjCC,EAAAA,SAAS,EAAE,IAAI;AACfC,EAAAA,mBAAmB,EAAE,CAAC;AACtBC,EAAAA,MAAM,EAAE,KAAK;AACbC,EAAAA,OAAO,EAAE,IAAA;CACD,CAAA;AACH,IAAMC,kBAAkB,GAC7B,4YAA4Y,CAAA;AACvY,IAAMC,qBAAqB,GAAG,2DAA2D,CAAA;AAEhG;;;;;;;;;;;;;;AAcG;AACqB,SAAAC,iBAAiBA,CACvCC,qBAA2E,EAC3EC,aAA2D,EAC3DC,qBACAC,gBAA+C,EAC/CC,UAA0B;AAAA,EAAA,IAF1BF;IAAAA,sBAAyE,EAAE,CAAA;AAAA,GAAA;AAAA,EAAA,IAE3EE;AAAAA,IAAAA,WAAuBC,uBAAG,CAAA;AAAA,GAAA;EAE1B,IAAMC,GAAG,GAAG,IAAIF,QAAQ,CAAAG,QAAA,CAAMf,EAAAA,EAAAA,UAAU,EAAKU,mBAAmB,CAAG,CAAA,CAAA;AACnE,EAAA,IAAIC,gBAAgB,EAAE;AACpBK,IAAAA,8BAAU,CAACF,GAAG,EAAEH,gBAAgB,CAAC,CAAA;AAClC,GAAA,MAAM,IAAIA,gBAAgB,KAAK,KAAK,EAAE;IACrCK,8BAAU,CAACF,GAAG,CAAC,CAAA;AAChB,GAAA;AAED;AACAA,EAAAA,GAAG,CAACG,SAAS,CAAC,UAAU,EAAEX,qBAAqB,CAAC,CAAA;AAChDQ,EAAAA,GAAG,CAACG,SAAS,CAAC,OAAO,EAAEZ,kBAAkB,CAAC,CAAA;AAE1C;AACAS,EA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AAII,iBAA+C,CAAA;AACnD,MAAA,IAAI2B,qBAAqB,CAAC,KAAK,CAAC,EAAE;QAChC3B,iBAAiB,GAAG,IAAI,CAACxD,GAAG,CAACyD,SAAS,CAAC0B,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;AACrE,OAAA;MACD,IAAI3B,iBAAiB,KAAKD,SAAS,EAAE;QACnCC,iBAAiB,GAAG,IAAI,CAACxD,GAAG,CAAC0D,OAAO,CAACyB,qBAAqB,CAAC,CAAA;AAC5D,OAAA;AACD,MAAA,IAAME,MAAM,GAAG7B,iBAAiB,CAACH,QAAQ,CAAC,CAAA;AAC1C,MAAA,OAAOgC,MAAiB,CAAA;KACzB,CAAC,OAAO1D,CAAC,EAAE;AACV2D,MAAAA,OAAO,CAACC,IAAI,CAAC,qCAAqC,EAAE5D,CAAC,CAAC,CAAA;AACtD,MAAA,OAAO,KAAK,CAAA;AACb,KAAA,SAAS;AACR;AACA;AACA,MAAA,IAAI,CAAC3B,GAAG,CAACwF,YAAY,CAACR,YAAY,CAAC,CAAA;AACpC,KAAA;GACF,CAAA;AAAA,EAAA,OAAAjE,aAAA,CAAA;AAAA,CAAA,EAAA;;ACvPH;;;;;AAKG;AACqB,SAAA0E,kBAAkBA,CAIxCzE,OAAsC,EAAIC,SAAqB,EAAA;AAAA,EAAA,IAA/DD,OAAsC,KAAA,KAAA,CAAA,EAAA;IAAtCA,OAAsC,GAAA,EAAE,CAAA;AAAA,GAAA;AACxC,EAAA,OAAO,IAAID,aAAa,CAAUC,OAAO,EAAEC,SAAS,CAAC,CAAA;AACvD;;ACZA,YAAA,aAAewE,kBAAkB,EAAE;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("lodash/toPath"),e=require("lodash/isPlainObject"),t=require("lodash/clone"),a=require("@rjsf/utils"),i=require("lodash/get"),o=require("ajv"),n=require("ajv-formats"),s=require("lodash/isObject");function c(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var u=c(r),d=c(e),l=c(t),f=c(i),h=c(o),v=c(n),m=c(s);function p(){return p=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},p.apply(this,arguments)}var y={allErrors:!0,multipleOfPrecision:8,strict:!1,verbose:!0},E=/^(#?([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*\)))$/,g=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/,j=["instancePath","keyword","params","schemaPath","parentSchema"],O=function(){function r(r,e){this.ajv=void 0,this.localizer=void 0,this.ajv=function(r,e,t,i,o){void 0===t&&(t={}),void 0===o&&(o=h.default);var n=new o(p({},y,t));return i?v.default(n,i):!1!==i&&v.default(n),n.addFormat("data-url",g),n.addFormat("color",E),n.addKeyword(a.ADDITIONAL_PROPERTY_FLAG),n.addKeyword(a.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&n.addMetaSchema(r),m.default(e)&&Object.keys(e).forEach((function(r){n.addFormat(r,e[r])})),n}(r.additionalMetaSchemas,r.customFormats,r.ajvOptionsOverrides,r.ajvFormatOptions,r.AjvClass),this.localizer=e}var e=r.prototype;return e.toErrorSchema=function(r){var e=new a.ErrorSchemaBuilder;return r.length&&r.forEach((function(r){var t=r.message,a=u.default(r.property);a.length>0&&""===a[0]&&a.splice(0,1),t&&e.addErrors(t,a)})),e.ErrorSchema},e.toErrorList=function(r,e){var t=this;if(void 0===e&&(e=[]),!r)return[];var i=[];return a.ERRORS_KEY in r&&(i=i.concat(r[a.ERRORS_KEY].map((function(r){var t="."+e.join(".");return{property:t,message:r,stack:t+" "+r}})))),Object.keys(r).reduce((function(i,o){if(o!==a.ERRORS_KEY){var n=r[o];d.default(n)&&(i=i.concat(t.toErrorList(n,[].concat(e,[o]))))}return i}),i)},e.createErrorHandler=function(r){var e=this,t={__errors:[],addError:function(r){this.__errors.push(r)}};if(Array.isArray(r))return r.reduce((function(r,t,a){var i;return p({},r,((i={})[a]=e.createErrorHandler(t),i))}),t);if(d.default(r)){var a=r;return Object.keys(a).reduce((function(r,t){var i;return p({},r,((i={})[t]=e.createErrorHandler(a[t]),i))}),t)}return t},e.unwrapErrorHandler=function(r){var e=this;return Object.keys(r).reduce((function(t,a){if("addError"===a)return t;var i,o,n=r[a];return d.default(n)?p({},t,((o={})[a]=e.unwrapErrorHandler(n),o)):p({},t,((i={})[a]=n,i))}),{})},e.transformRJSFValidationErrors=function(r,e){return void 0===r&&(r=[]),r.map((function(r){var t=r.instancePath,i=r.keyword,o=r.params,n=r.schemaPath,s=r.parentSchema,c=function(r,e){if(null==r)return{};var t,a,i={},o=Object.keys(r);for(a=0;a<o.length;a++)e.indexOf(t=o[a])>=0||(i[t]=r[t]);return i}(r,j).message,u=void 0===c?"":c,d=t.replace(/\//g,"."),l=(d+" "+u).trim();if("missingProperty"in o){var h=o.missingProperty,v=a.getUiOptions(f.default(e,""+(d=d?d+"."+o.missingProperty:o.missingProperty).replace(/^\./,""))).title;if(v)u=u.replace(h,v);else{var m=f.default(s,[a.PROPERTIES_KEY,h,"title"]);m&&(u=u.replace(h,m))}l=u}else{var p=a.getUiOptions(f.default(e,""+d.replace(/^\./,""))).title;if(p)l=("'"+p+"' "+u).trim();else{var y=null==s?void 0:s.title;y&&(l=("'"+y+"' "+u).trim())}}return{name:i,property:d,message:u,params:o,stack:l,schemaPath:n}}))},e.rawValidation=function(r,e){var t,a,i=void 0;r.$id&&(t=this.ajv.getSchema(r.$id));try{void 0===t&&(t=this.ajv.compile(r)),t(e)}catch(r){i=r}return t&&("function"==typeof this.localizer&&this.localizer(t.errors),a=t.errors||void 0,t.errors=null),{errors:a,validationError:i}},e.validateFormData=function(r,e,t,i,o){var n=this.rawValidation(e,r),s=n.validationError,c=this.transformRJSFValidationErrors(n.errors,o);s&&(c=[].concat(c,[{stack:s.message}])),"function"==typeof i&&(c=i(c,o));var u=this.toErrorSchema(c);if(s&&(u=p({},u,{$schema:{__errors:[s.message]}})),"function"!=typeof t)return{errors:c,errorSchema:u};var d=a.getDefaultFormState(this,e,r,e,!0),l=t(d,this.createErrorHandler(d),o),f=this.unwrapErrorHandler(l);return a.mergeValidationData(this,{errors:c,errorSchema:u},f)},e.withIdRefPrefixObject=function(r){for(var e in r){var t=r[e];r[e]=e===a.REF_KEY&&"string"==typeof t&&t.startsWith("#")?"__rjsf_rootSchema"+t:this.withIdRefPrefix(t)}return r},e.withIdRefPrefixArray=function(r){for(var e=0;e<r.length;e++)r[e]=this.withIdRefPrefix(r[e]);return r},e.isValid=function(r,e,t){var a,i=null!=(a=t.$id)?a:"__rjsf_rootSchema";try{void 0===this.ajv.getSchema(i)&&this.ajv.addSchema(t,i);var o,n=this.withIdRefPrefix(r);return n.$id&&(o=this.ajv.getSchema(n.$id)),void 0===o&&(o=this.ajv.compile(n)),o(e)}catch(r){return console.warn("Error encountered compiling schema:",r),!1}finally{this.ajv.removeSchema(i)}},e.withIdRefPrefix=function(r){return Array.isArray(r)?this.withIdRefPrefixArray([].concat(r)):d.default(r)?this.withIdRefPrefixObject(l.default(r)):r},r}();function b(r,e){return void 0===r&&(r={}),new O(r,e)}var P=b();exports.customizeValidator=b,exports.default=P;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("lodash/get"),e=require("@rjsf/utils"),a=require("ajv"),t=require("ajv-formats"),i=require("lodash/isObject");function o(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var s=o(r),n=o(a),l=o(t),d=o(i);function c(){return c=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(r[t]=a[t])}return r},c.apply(this,arguments)}var u={allErrors:!0,multipleOfPrecision:8,strict:!1,verbose:!0},v=/^(#?([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*\)))$/,f=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/,m=["instancePath","keyword","params","schemaPath","parentSchema"],h=function(){function r(r,a){this.ajv=void 0,this.localizer=void 0,this.ajv=function(r,a,t,i,o){void 0===t&&(t={}),void 0===o&&(o=n.default);var s=new o(c({},u,t));return i?l.default(s,i):!1!==i&&l.default(s),s.addFormat("data-url",f),s.addFormat("color",v),s.addKeyword(e.ADDITIONAL_PROPERTY_FLAG),s.addKeyword(e.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&s.addMetaSchema(r),d.default(a)&&Object.keys(a).forEach((function(r){s.addFormat(r,a[r])})),s}(r.additionalMetaSchemas,r.customFormats,r.ajvOptionsOverrides,r.ajvFormatOptions,r.AjvClass),this.localizer=a}var a=r.prototype;return a.toErrorList=function(r,a){return void 0===a&&(a=[]),e.toErrorList(r,a)},a.transformRJSFValidationErrors=function(r,a){return void 0===r&&(r=[]),r.map((function(r){var t=r.instancePath,i=r.keyword,o=r.params,n=r.schemaPath,l=r.parentSchema,d=function(r,e){if(null==r)return{};var a,t,i={},o=Object.keys(r);for(t=0;t<o.length;t++)e.indexOf(a=o[t])>=0||(i[a]=r[a]);return i}(r,m).message,c=void 0===d?"":d,u=t.replace(/\//g,"."),v=(u+" "+c).trim();if("missingProperty"in o){var f=o.missingProperty,h=e.getUiOptions(s.default(a,""+(u=u?u+"."+o.missingProperty:o.missingProperty).replace(/^\./,""))).title;if(h)c=c.replace(f,h);else{var p=s.default(l,[e.PROPERTIES_KEY,f,"title"]);p&&(c=c.replace(f,p))}v=c}else{var y=e.getUiOptions(s.default(a,""+u.replace(/^\./,""))).title;if(y)v=("'"+y+"' "+c).trim();else{var g=null==l?void 0:l.title;g&&(v=("'"+g+"' "+c).trim())}}return{name:i,property:u,message:c,params:o,stack:v,schemaPath:n}}))},a.rawValidation=function(r,e){var a,t,i=void 0;r.$id&&(a=this.ajv.getSchema(r.$id));try{void 0===a&&(a=this.ajv.compile(r)),a(e)}catch(r){i=r}return a&&("function"==typeof this.localizer&&this.localizer(a.errors),t=a.errors||void 0,a.errors=null),{errors:t,validationError:i}},a.validateFormData=function(r,a,t,i,o){var s=this.rawValidation(a,r),n=s.validationError,l=this.transformRJSFValidationErrors(s.errors,o);n&&(l=[].concat(l,[{stack:n.message}])),"function"==typeof i&&(l=i(l,o));var d=e.toErrorSchema(l);if(n&&(d=c({},d,{$schema:{__errors:[n.message]}})),"function"!=typeof t)return{errors:l,errorSchema:d};var u=e.getDefaultFormState(this,a,r,a,!0),v=t(u,e.createErrorHandler(u),o),f=e.unwrapErrorHandler(v);return e.validationDataMerge({errors:l,errorSchema:d},f)},a.isValid=function(r,a,t){var i,o=null!=(i=t.$id)?i:e.ROOT_SCHEMA_PREFIX;try{void 0===this.ajv.getSchema(o)&&this.ajv.addSchema(t,o);var s,n=e.withIdRefPrefix(r);return n.$id&&(s=this.ajv.getSchema(n.$id)),void 0===s&&(s=this.ajv.compile(n)),s(a)}catch(r){return console.warn("Error encountered compiling schema:",r),!1}finally{this.ajv.removeSchema(o)}},r}();function p(r,e){return void 0===r&&(r={}),new h(r,e)}var y=p();exports.customizeValidator=p,exports.default=y;
2
2
  //# sourceMappingURL=validator-ajv8.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validator-ajv8.cjs.production.min.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 toPath from 'lodash/toPath';\nimport isPlainObject from 'lodash/isPlainObject';\nimport clone from 'lodash/clone';\nimport {\n CustomValidator,\n ERRORS_KEY,\n ErrorSchema,\n ErrorSchemaBuilder,\n ErrorTransformer,\n FieldValidation,\n FormContextType,\n FormValidation,\n GenericObjectType,\n getDefaultFormState,\n mergeValidationData,\n REF_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n UiSchema,\n ValidationData,\n ValidatorType,\n PROPERTIES_KEY,\n getUiOptions,\n} from '@rjsf/utils';\nimport get from 'lodash/get';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\n\nconst ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';\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 /** Transforms a ajv validation errors list:\n * [\n * {property: '.level1.level2[2].level3', message: 'err a'},\n * {property: '.level1.level2[2].level3', message: 'err b'},\n * {property: '.level1.level2[4].level3', message: 'err b'},\n * ]\n * Into an error tree:\n * {\n * level1: {\n * level2: {\n * 2: {level3: {errors: ['err a', 'err b']}},\n * 4: {level3: {errors: ['err b']}},\n * }\n * }\n * };\n *\n * @param errors - The list of RJSFValidationError objects\n * @private\n */\n private toErrorSchema(errors: RJSFValidationError[]): ErrorSchema<T> {\n const builder = new ErrorSchemaBuilder<T>();\n if (errors.length) {\n errors.forEach((error) => {\n const { property, message } = error;\n const path = toPath(property);\n\n // If the property is at the root (.level1) then toPath creates\n // an empty array element at the first index. Remove it.\n if (path.length > 0 && path[0] === '') {\n path.splice(0, 1);\n }\n if (message) {\n builder.addErrors(message, path);\n }\n });\n }\n return builder.ErrorSchema;\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 */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n if (!errorSchema) {\n return [];\n }\n let errorList: RJSFValidationError[] = [];\n if (ERRORS_KEY in errorSchema) {\n errorList = errorList.concat(\n errorSchema[ERRORS_KEY]!.map((message: string) => {\n const property = `.${fieldPath.join('.')}`;\n return {\n property,\n message,\n stack: `${property} ${message}`,\n };\n })\n );\n }\n return Object.keys(errorSchema).reduce((acc, key) => {\n if (key !== ERRORS_KEY) {\n const childSchema = (errorSchema as GenericObjectType)[key];\n if (isPlainObject(childSchema)) {\n acc = acc.concat(this.toErrorList(childSchema, [...fieldPath, key]));\n }\n }\n return acc;\n }, errorList);\n }\n\n /** Given a `formData` object, recursively creates a `FormValidation` error handling structure around it\n *\n * @param formData - The form data around which the error handler is created\n * @private\n */\n private createErrorHandler(formData: T): FormValidation<T> {\n const handler: FieldValidation = {\n // We store the list of errors for this node in a property named __errors\n // to avoid name collision with a possible sub schema field named\n // 'errors' (see `utils.toErrorSchema`).\n __errors: [],\n addError(message: string) {\n this.__errors!.push(message);\n },\n };\n if (Array.isArray(formData)) {\n return formData.reduce((acc, value, key) => {\n return { ...acc, [key]: this.createErrorHandler(value) };\n }, handler);\n }\n if (isPlainObject(formData)) {\n const formObject: GenericObjectType = formData as GenericObjectType;\n return Object.keys(formObject).reduce((acc, key) => {\n return { ...acc, [key]: this.createErrorHandler(formObject[key]) };\n }, handler as FormValidation<T>);\n }\n return handler as FormValidation<T>;\n }\n\n /** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError` functions from it\n *\n * @param errorHandler - The `FormValidation` error handling structure\n * @private\n */\n private unwrapErrorHandler(errorHandler: FormValidation<T>): ErrorSchema<T> {\n return Object.keys(errorHandler).reduce((acc, key) => {\n if (key === 'addError') {\n return acc;\n } else {\n const childSchema = (errorHandler as GenericObjectType)[key];\n if (isPlainObject(childSchema)) {\n return {\n ...acc,\n [key]: this.unwrapErrorHandler(childSchema),\n };\n }\n return { ...acc, [key]: childSchema };\n }\n }, {} as ErrorSchema<T>);\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 * @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(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 = this.toErrorSchema(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, this.createErrorHandler(newFormData), uiSchema);\n const userErrorSchema = this.unwrapErrorHandler(errorHandler);\n return mergeValidationData<T, S, F>(this, { errors, errorSchema }, userErrorSchema);\n }\n\n /** Takes a `node` object and transforms any contained `$ref` node variables with a prefix, recursively calling\n * `withIdRefPrefix` for any other elements.\n *\n * @param node - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n * @private\n */\n private withIdRefPrefixObject(node: S) {\n for (const key in node) {\n const realObj: GenericObjectType = node;\n const value = realObj[key];\n if (key === REF_KEY && typeof value === 'string' && value.startsWith('#')) {\n realObj[key] = ROOT_SCHEMA_PREFIX + value;\n } else {\n realObj[key] = this.withIdRefPrefix(value);\n }\n }\n return node;\n }\n\n /** Takes a `node` object list and transforms any contained `$ref` node variables with a prefix, recursively calling\n * `withIdRefPrefix` for any other elements.\n *\n * @param node - The list of object nodes to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n * @private\n */\n private withIdRefPrefixArray(node: S[]): S[] {\n for (let i = 0; i < node.length; i++) {\n node[i] = this.withIdRefPrefix(node[i]) as S;\n }\n return node;\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 = this.withIdRefPrefix(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 /** Recursively prefixes all $ref's in a schema with `ROOT_SCHEMA_PREFIX`\n * This is used in isValid to make references to the rootSchema\n *\n * @param schemaNode - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n * @protected\n */\n protected withIdRefPrefix(schemaNode: S | S[]): S | S[] {\n if (Array.isArray(schemaNode)) {\n return this.withIdRefPrefixArray([...schemaNode]);\n }\n if (isPlainObject(schemaNode)) {\n return this.withIdRefPrefixObject(clone<S>(schemaNode));\n }\n return schemaNode;\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","AJV8Validator","options","localizer","this","ajv","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","_extends","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName","createAjvInstance","_proto","prototype","toErrorSchema","errors","builder","ErrorSchemaBuilder","length","error","message","path","toPath","property","splice","addErrors","ErrorSchema","toErrorList","errorSchema","fieldPath","_this","errorList","ERRORS_KEY","concat","map","join","stack","reduce","acc","key","childSchema","isPlainObject","createErrorHandler","formData","_this2","handler","__errors","addError","push","value","_extends2","formObject","_extends3","unwrapErrorHandler","errorHandler","_this3","_extends5","_extends4","transformRJSFValidationErrors","uiSchema","e","instancePath","keyword","params","schemaPath","parentSchema","_rest$message","_objectWithoutPropertiesLoose","_excluded","replace","trim","currentProperty","missingProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","rawValidation","schema","compiledValidator","compilationError","undefined","getSchema","compile","err","validationError","validateFormData","customValidate","transformErrors","rawErrors","invalidSchemaError","$schema","newFormData","getDefaultFormState","userErrorSchema","mergeValidationData","withIdRefPrefixObject","node","REF_KEY","startsWith","withIdRefPrefix","withIdRefPrefixArray","i","isValid","rootSchema","_rootSchema$$id","rootSchemaId","addSchema","schemaWithIdRefPrefix","console","warn","removeSchema","schemaNode","clone","customizeValidator","index"],"mappings":"wnBAOO,IAAMA,EAAsB,CACjCC,WAAW,EACXC,oBAAqB,EACrBC,QAAQ,EACRC,SAAS,GAEEC,EACX,6YACWC,EAAwB,8HCoBhBC,EAAa,WAoBhC,SAAAA,EAAYC,EAAqCC,GAjBjDC,KAIQC,SAAG,EAEXD,KAISD,eAAS,EAShBC,KAAKC,IDzBe,SACtBC,EACAC,EACAC,EACAC,EACAC,YAFAF,IAAAA,EAAyE,CAAA,YAEzEE,IAAAA,EAAuBC,EAAAA,SAEvB,IAAMN,EAAM,IAAIK,EAAQE,EAAMlB,CAAAA,EAAAA,EAAec,IA2B7C,OA1BIC,EACFI,UAAWR,EAAKI,IACc,IAArBA,GACTI,EAAU,QAACR,GAIbA,EAAIS,UAAU,WAAYd,GAC1BK,EAAIS,UAAU,QAASf,GAGvBM,EAAIU,WAAWC,EAAAA,0BACfX,EAAIU,WAAWE,EAAAA,gCAGXC,MAAMC,QAAQb,IAChBD,EAAIe,cAAcd,GAIhBe,EAAAA,QAASd,IACXe,OAAOC,KAAKhB,GAAeiB,SAAQ,SAACC,GAClCpB,EAAIS,UAAUW,EAAYlB,EAAckB,GAC1C,IAGKpB,CACT,CCVeqB,CADuFxB,EAA1FI,sBAA0FJ,EAAnEK,cAAmEL,EAApDM,oBAAoDN,EAA/BO,iBAA+BP,EAAbQ,UAErFN,KAAKD,UAAYA,CACnB,CAEA,IAAAwB,EAAA1B,EAAA2B,UAmWC,OAnWDD,EAmBQE,cAAA,SAAcC,GACpB,IAAMC,EAAU,IAAIC,EAAAA,mBAgBpB,OAfIF,EAAOG,QACTH,EAAON,SAAQ,SAACU,GACd,IAAkBC,EAAYD,EAAZC,QACZC,EAAOC,UADiBH,EAAtBI,UAKJF,EAAKH,OAAS,GAAiB,KAAZG,EAAK,IAC1BA,EAAKG,OAAO,EAAG,GAEbJ,GACFJ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SAAgBY,GACxB,OAAIhH,MAAMC,QAAQ+G,GACT9H,KAAKmH,wBAAoBvE,OAAKkF,IAEnC1E,EAAAA,QAAc0E,GACT9H,KAAK8G,sBAAsBiB,UAASD,IAEtCA,GACRjI,CAAA,CA7X+B,GCxBV,SAAAmI,EAItBlI,EAA0CC,GAC1C,YADsC,IAAtCD,IAAAA,EAAsC,CAAA,GAC/B,IAAID,EAAuBC,EAASC,EAC7C,CCZA,IAAAkI,EAAeD"}
1
+ {"version":3,"file":"validator-ajv8.cjs.production.min.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","AJV8Validator","options","localizer","this","ajv","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","_extends","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName","createAjvInstance","_proto","prototype","toErrorList","errorSchema","fieldPath","transformRJSFValidationErrors","errors","uiSchema","map","e","instancePath","keyword","params","schemaPath","parentSchema","_rest$message","_objectWithoutPropertiesLoose","_excluded","message","property","replace","stack","trim","currentProperty","missingProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","rawValidation","schema","formData","compiledValidator","compilationError","undefined","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","console","warn","removeSchema","customizeValidator","index"],"mappings":"4gBAOO,IAAMA,EAAsB,CACjCC,WAAW,EACXC,oBAAqB,EACrBC,QAAQ,EACRC,SAAS,GAEEC,EACX,6YACWC,EAAwB,8HCehBC,EAAa,WAoBhC,SAAAA,EAAYC,EAAqCC,GAjBjD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