@rjsf/validator-ajv8 5.10.0 → 5.11.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,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var createAjvInstance = require('./createAjvInstance-0cd8cfba.js');
6
5
  var fs = require('fs');
7
6
  var standaloneCode = require('ajv/dist/standalone');
8
7
  var utils = require('@rjsf/utils');
8
+ var createAjvInstance = require('./createAjvInstance-33d73c95.js');
9
9
  require('ajv');
10
10
  require('ajv-formats');
11
11
  require('lodash/isObject');
@@ -26,32 +26,30 @@ var standaloneCode__default = /*#__PURE__*/_interopDefaultLegacy(standaloneCode)
26
26
  * compiling the schema. They are the same options that are passed to the `customizeValidator()` function in
27
27
  * order to modify the behavior of the regular AJV-based validator.
28
28
  */
29
- function compileSchemaValidators(schema, output, options) {
30
- if (options === void 0) {
31
- options = {};
32
- }
29
+ function compileSchemaValidators(schema, output, options = {}) {
33
30
  console.log('parsing the schema');
34
- var schemaMaps = utils.schemaParser(schema);
35
- var schemas = Object.values(schemaMaps);
36
- var _options = options,
37
- additionalMetaSchemas = _options.additionalMetaSchemas,
38
- customFormats = _options.customFormats,
39
- _options$ajvOptionsOv = _options.ajvOptionsOverrides,
40
- ajvOptionsOverrides = _options$ajvOptionsOv === void 0 ? {} : _options$ajvOptionsOv,
41
- ajvFormatOptions = _options.ajvFormatOptions,
42
- AjvClass = _options.AjvClass;
31
+ const schemaMaps = utils.schemaParser(schema);
32
+ const schemas = Object.values(schemaMaps);
33
+ const {
34
+ additionalMetaSchemas,
35
+ customFormats,
36
+ ajvOptionsOverrides = {},
37
+ ajvFormatOptions,
38
+ AjvClass
39
+ } = options;
43
40
  // Allow users to turn off the `lines: true` feature in their own overrides, but NOT the `source: true`
44
- var compileOptions = createAjvInstance._extends({}, ajvOptionsOverrides, {
45
- code: createAjvInstance._extends({
46
- lines: true
47
- }, ajvOptionsOverrides.code, {
41
+ const compileOptions = {
42
+ ...ajvOptionsOverrides,
43
+ code: {
44
+ lines: true,
45
+ ...ajvOptionsOverrides.code,
48
46
  source: true
49
- }),
50
- schemas: schemas
51
- });
52
- var ajv = createAjvInstance.createAjvInstance(additionalMetaSchemas, customFormats, compileOptions, ajvFormatOptions, AjvClass);
53
- var moduleCode = standaloneCode__default["default"](ajv);
54
- console.log("writing " + output);
47
+ },
48
+ schemas
49
+ };
50
+ const ajv = createAjvInstance.createAjvInstance(additionalMetaSchemas, customFormats, compileOptions, ajvFormatOptions, AjvClass);
51
+ const moduleCode = standaloneCode__default["default"](ajv);
52
+ console.log(`writing ${output}`);
55
53
  fs__default["default"].writeFileSync(output, moduleCode);
56
54
  }
57
55
 
@@ -1 +1 @@
1
- {"version":3,"file":"compileSchemaValidators.cjs.development.js","sources":["../src/compileSchemaValidators.ts"],"sourcesContent":["import fs from 'fs';\nimport standaloneCode from 'ajv/dist/standalone';\nimport { RJSFSchema, StrictRJSFSchema, schemaParser } from '@rjsf/utils';\n\nimport createAjvInstance from './createAjvInstance';\nimport { CustomValidatorOptionsType } from './types';\n\n/** The function used to compile a schema into an output file in the form that allows it to be used as a precompiled\n * validator. The main reasons for using a precompiled validator is reducing code size, improving validation speed and,\n * most importantly, avoiding dynamic code compilation when prohibited by a browser's Content Security Policy. For more\n * information about AJV code compilation see: https://ajv.js.org/standalone.html\n *\n * @param schema - The schema to be compiled into a set of precompiled validators functions\n * @param output - The name of the file into which the precompiled validator functions will be generated\n * @param [options={}] - The set of `CustomValidatorOptionsType` information used to alter the AJV validator used for\n * compiling the schema. They are the same options that are passed to the `customizeValidator()` function in\n * order to modify the behavior of the regular AJV-based validator.\n */\nexport default function compileSchemaValidators<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n output: string,\n options: CustomValidatorOptionsType = {}\n) {\n console.log('parsing the schema');\n const schemaMaps = schemaParser(schema);\n const schemas = Object.values(schemaMaps);\n\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides = {}, ajvFormatOptions, AjvClass } = options;\n // Allow users to turn off the `lines: true` feature in their own overrides, but NOT the `source: true`\n const compileOptions = {\n ...ajvOptionsOverrides,\n code: { lines: true, ...ajvOptionsOverrides.code, source: true },\n schemas,\n };\n const ajv = createAjvInstance(additionalMetaSchemas, customFormats, compileOptions, ajvFormatOptions, AjvClass);\n\n const moduleCode = standaloneCode(ajv);\n console.log(`writing ${output}`);\n fs.writeFileSync(output, moduleCode);\n}\n"],"names":["compileSchemaValidators","schema","output","options","console","log","schemaMaps","schemaParser","schemas","Object","values","_options","additionalMetaSchemas","customFormats","_options$ajvOptionsOv","ajvOptionsOverrides","ajvFormatOptions","AjvClass","compileOptions","_extends","code","lines","source","ajv","createAjvInstance","moduleCode","standaloneCode","fs","writeFileSync"],"mappings":";;;;;;;;;;;;;;;;;AAOA;;;;;;;;;;AAUG;AACW,SAAUA,uBAAuBA,CAC7CC,MAAS,EACTC,MAAc,EACdC,OAAA,EAAwC;AAAA,EAAA,IAAxCA,OAAA,KAAA,KAAA,CAAA,EAAA;IAAAA,OAAA,GAAsC,EAAE,CAAA;AAAA,GAAA;AAExCC,EAAAA,OAAO,CAACC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AACjC,EAAA,IAAMC,UAAU,GAAGC,kBAAY,CAACN,MAAM,CAAC,CAAA;AACvC,EAAA,IAAMO,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACJ,UAAU,CAAC,CAAA;EAEzC,IAAAK,QAAA,GAAuGR,OAAO;IAAtGS,qBAAqB,GAAAD,QAAA,CAArBC,qBAAqB;IAAEC,aAAa,GAAAF,QAAA,CAAbE,aAAa;IAAAC,qBAAA,GAAAH,QAAA,CAAEI,mBAAmB;AAAnBA,IAAAA,mBAAmB,GAAAD,qBAAA,KAAA,KAAA,CAAA,GAAG,EAAE,GAAAA,qBAAA;IAAEE,gBAAgB,GAAAL,QAAA,CAAhBK,gBAAgB;IAAEC,QAAQ,GAAAN,QAAA,CAARM,QAAQ,CAAA;AAClG;AACA,EAAA,IAAMC,cAAc,GAAAC,0BAAA,CAAA,EAAA,EACfJ,mBAAmB,EAAA;AACtBK,IAAAA,IAAI,EAAAD,0BAAA,CAAA;AAAIE,MAAAA,KAAK,EAAE,IAAA;KAASN,EAAAA,mBAAmB,CAACK,IAAI,EAAA;AAAEE,MAAAA,MAAM,EAAE,IAAA;KAAM,CAAA;AAChEd,IAAAA,OAAO,EAAPA,OAAAA;GACD,CAAA,CAAA;AACD,EAAA,IAAMe,GAAG,GAAGC,mCAAiB,CAACZ,qBAAqB,EAAEC,aAAa,EAAEK,cAAc,EAAEF,gBAAgB,EAAEC,QAAQ,CAAC,CAAA;AAE/G,EAAA,IAAMQ,UAAU,GAAGC,kCAAc,CAACH,GAAG,CAAC,CAAA;AACtCnB,EAAAA,OAAO,CAACC,GAAG,CAAYH,UAAAA,GAAAA,MAAQ,CAAC,CAAA;AAChCyB,EAAAA,sBAAE,CAACC,aAAa,CAAC1B,MAAM,EAAEuB,UAAU,CAAC,CAAA;AACtC;;;;"}
1
+ {"version":3,"file":"compileSchemaValidators.cjs.development.js","sources":["../src/compileSchemaValidators.ts"],"sourcesContent":["import fs from 'fs';\nimport standaloneCode from 'ajv/dist/standalone';\nimport { RJSFSchema, StrictRJSFSchema, schemaParser } from '@rjsf/utils';\n\nimport createAjvInstance from './createAjvInstance';\nimport { CustomValidatorOptionsType } from './types';\n\n/** The function used to compile a schema into an output file in the form that allows it to be used as a precompiled\n * validator. The main reasons for using a precompiled validator is reducing code size, improving validation speed and,\n * most importantly, avoiding dynamic code compilation when prohibited by a browser's Content Security Policy. For more\n * information about AJV code compilation see: https://ajv.js.org/standalone.html\n *\n * @param schema - The schema to be compiled into a set of precompiled validators functions\n * @param output - The name of the file into which the precompiled validator functions will be generated\n * @param [options={}] - The set of `CustomValidatorOptionsType` information used to alter the AJV validator used for\n * compiling the schema. They are the same options that are passed to the `customizeValidator()` function in\n * order to modify the behavior of the regular AJV-based validator.\n */\nexport default function compileSchemaValidators<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n output: string,\n options: CustomValidatorOptionsType = {}\n) {\n console.log('parsing the schema');\n const schemaMaps = schemaParser(schema);\n const schemas = Object.values(schemaMaps);\n\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides = {}, ajvFormatOptions, AjvClass } = options;\n // Allow users to turn off the `lines: true` feature in their own overrides, but NOT the `source: true`\n const compileOptions = {\n ...ajvOptionsOverrides,\n code: { lines: true, ...ajvOptionsOverrides.code, source: true },\n schemas,\n };\n const ajv = createAjvInstance(additionalMetaSchemas, customFormats, compileOptions, ajvFormatOptions, AjvClass);\n\n const moduleCode = standaloneCode(ajv);\n console.log(`writing ${output}`);\n fs.writeFileSync(output, moduleCode);\n}\n"],"names":["compileSchemaValidators","schema","output","options","console","log","schemaMaps","schemaParser","schemas","Object","values","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","compileOptions","code","lines","source","ajv","createAjvInstance","moduleCode","standaloneCode","fs","writeFileSync"],"mappings":";;;;;;;;;;;;;;;;;AAOA;;;;;;;;;;AAUG;AACW,SAAUA,uBAAuBA,CAC7CC,MAAS,EACTC,MAAc,EACdC,OAAA,GAAsC,EAAE,EAAA;AAExCC,EAAAA,OAAO,CAACC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AACjC,EAAA,MAAMC,UAAU,GAAGC,kBAAY,CAACN,MAAM,CAAC,CAAA;AACvC,EAAA,MAAMO,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACJ,UAAU,CAAC,CAAA;EAEzC,MAAM;IAAEK,qBAAqB;IAAEC,aAAa;IAAEC,mBAAmB,GAAG,EAAE;IAAEC,gBAAgB;AAAEC,IAAAA,QAAAA;AAAU,GAAA,GAAGZ,OAAO,CAAA;AAC9G;AACA,EAAA,MAAMa,cAAc,GAAG;AACrB,IAAA,GAAGH,mBAAmB;AACtBI,IAAAA,IAAI,EAAE;AAAEC,MAAAA,KAAK,EAAE,IAAI;MAAE,GAAGL,mBAAmB,CAACI,IAAI;AAAEE,MAAAA,MAAM,EAAE,IAAA;KAAM;AAChEX,IAAAA,OAAAA;GACD,CAAA;AACD,EAAA,MAAMY,GAAG,GAAGC,mCAAiB,CAACV,qBAAqB,EAAEC,aAAa,EAAEI,cAAc,EAAEF,gBAAgB,EAAEC,QAAQ,CAAC,CAAA;AAE/G,EAAA,MAAMO,UAAU,GAAGC,kCAAc,CAACH,GAAG,CAAC,CAAA;AACtChB,EAAAA,OAAO,CAACC,GAAG,EAAYH,QAAAA,EAAAA,MAAM,EAAE,CAAC,CAAA;AAChCsB,EAAAA,sBAAE,CAACC,aAAa,CAACvB,MAAM,EAAEoB,UAAU,CAAC,CAAA;AACtC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./createAjvInstance-0cd8cfba.js"),r=require("fs"),t=require("ajv/dist/standalone"),s=require("@rjsf/utils");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("ajv"),require("ajv-formats"),require("lodash/isObject");var i=a(r),o=a(t);exports.default=function(r,t,a){void 0===a&&(a={}),console.log("parsing the schema");var c=s.schemaParser(r),n=Object.values(c),u=a.additionalMetaSchemas,d=a.customFormats,l=a.ajvOptionsOverrides,v=void 0===l?{}:l,j=a.ajvFormatOptions,f=a.AjvClass,m=e._extends({},v,{code:e._extends({lines:!0},v.code,{source:!0}),schemas:n}),p=e.createAjvInstance(u,d,m,j,f),q=o.default(p);console.log("writing "+t),i.default.writeFileSync(t,q)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),r=require("ajv/dist/standalone"),t=require("@rjsf/utils"),s=require("./createAjvInstance-33d73c95.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("ajv"),require("ajv-formats"),require("lodash/isObject");var o=a(e),i=a(r);exports.default=function(e,r,a={}){console.log("parsing the schema");const c=t.schemaParser(e),n=Object.values(c),{additionalMetaSchemas:u,customFormats:l,ajvOptionsOverrides:d={},ajvFormatOptions:j,AjvClass:v}=a,f={...d,code:{lines:!0,...d.code,source:!0},schemas:n},m=s.createAjvInstance(u,l,f,j,v),p=i.default(m);console.log(`writing ${r}`),o.default.writeFileSync(r,p)};
2
2
  //# sourceMappingURL=compileSchemaValidators.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compileSchemaValidators.cjs.production.min.js","sources":["../src/compileSchemaValidators.ts"],"sourcesContent":["import fs from 'fs';\nimport standaloneCode from 'ajv/dist/standalone';\nimport { RJSFSchema, StrictRJSFSchema, schemaParser } from '@rjsf/utils';\n\nimport createAjvInstance from './createAjvInstance';\nimport { CustomValidatorOptionsType } from './types';\n\n/** The function used to compile a schema into an output file in the form that allows it to be used as a precompiled\n * validator. The main reasons for using a precompiled validator is reducing code size, improving validation speed and,\n * most importantly, avoiding dynamic code compilation when prohibited by a browser's Content Security Policy. For more\n * information about AJV code compilation see: https://ajv.js.org/standalone.html\n *\n * @param schema - The schema to be compiled into a set of precompiled validators functions\n * @param output - The name of the file into which the precompiled validator functions will be generated\n * @param [options={}] - The set of `CustomValidatorOptionsType` information used to alter the AJV validator used for\n * compiling the schema. They are the same options that are passed to the `customizeValidator()` function in\n * order to modify the behavior of the regular AJV-based validator.\n */\nexport default function compileSchemaValidators<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n output: string,\n options: CustomValidatorOptionsType = {}\n) {\n console.log('parsing the schema');\n const schemaMaps = schemaParser(schema);\n const schemas = Object.values(schemaMaps);\n\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides = {}, ajvFormatOptions, AjvClass } = options;\n // Allow users to turn off the `lines: true` feature in their own overrides, but NOT the `source: true`\n const compileOptions = {\n ...ajvOptionsOverrides,\n code: { lines: true, ...ajvOptionsOverrides.code, source: true },\n schemas,\n };\n const ajv = createAjvInstance(additionalMetaSchemas, customFormats, compileOptions, ajvFormatOptions, AjvClass);\n\n const moduleCode = standaloneCode(ajv);\n console.log(`writing ${output}`);\n fs.writeFileSync(output, moduleCode);\n}\n"],"names":["schema","output","options","console","log","schemaMaps","schemaParser","schemas","Object","values","additionalMetaSchemas","customFormats","_options$ajvOptionsOv","ajvOptionsOverrides","ajvFormatOptions","AjvClass","compileOptions","_extends","code","lines","source","ajv","createAjvInstance","moduleCode","standaloneCode","fs","writeFileSync"],"mappings":"0WAkBc,SACZA,EACAC,EACAC,QAAA,IAAAA,IAAAA,EAAsC,CAAA,GAEtCC,QAAQC,IAAI,sBACZ,IAAMC,EAAaC,eAAaN,GAC1BO,EAAUC,OAAOC,OAAOJ,GAEtBK,EAA+FR,EAA/FQ,sBAAuBC,EAAwET,EAAxES,cAAaC,EAA2DV,EAAzDW,oBAAAA,OAAmB,IAAAD,EAAG,CAAE,EAAAA,EAAEE,EAA+BZ,EAA/BY,iBAAkBC,EAAab,EAAba,SAEpFC,EAAcC,EAAAA,SAAA,CAAA,EACfJ,EAAmB,CACtBK,KAAID,EAAAA,SAAA,CAAIE,OAAO,GAASN,EAAoBK,KAAI,CAAEE,QAAQ,IAC1Db,QAAAA,IAEIc,EAAMC,EAAAA,kBAAkBZ,EAAuBC,EAAeK,EAAgBF,EAAkBC,GAEhGQ,EAAaC,UAAeH,GAClClB,QAAQC,IAAeH,WAAAA,GACvBwB,EAAAA,QAAGC,cAAczB,EAAQsB,EAC3B"}
1
+ {"version":3,"file":"compileSchemaValidators.cjs.production.min.js","sources":["../src/compileSchemaValidators.ts"],"sourcesContent":["import fs from 'fs';\nimport standaloneCode from 'ajv/dist/standalone';\nimport { RJSFSchema, StrictRJSFSchema, schemaParser } from '@rjsf/utils';\n\nimport createAjvInstance from './createAjvInstance';\nimport { CustomValidatorOptionsType } from './types';\n\n/** The function used to compile a schema into an output file in the form that allows it to be used as a precompiled\n * validator. The main reasons for using a precompiled validator is reducing code size, improving validation speed and,\n * most importantly, avoiding dynamic code compilation when prohibited by a browser's Content Security Policy. For more\n * information about AJV code compilation see: https://ajv.js.org/standalone.html\n *\n * @param schema - The schema to be compiled into a set of precompiled validators functions\n * @param output - The name of the file into which the precompiled validator functions will be generated\n * @param [options={}] - The set of `CustomValidatorOptionsType` information used to alter the AJV validator used for\n * compiling the schema. They are the same options that are passed to the `customizeValidator()` function in\n * order to modify the behavior of the regular AJV-based validator.\n */\nexport default function compileSchemaValidators<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n output: string,\n options: CustomValidatorOptionsType = {}\n) {\n console.log('parsing the schema');\n const schemaMaps = schemaParser(schema);\n const schemas = Object.values(schemaMaps);\n\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides = {}, ajvFormatOptions, AjvClass } = options;\n // Allow users to turn off the `lines: true` feature in their own overrides, but NOT the `source: true`\n const compileOptions = {\n ...ajvOptionsOverrides,\n code: { lines: true, ...ajvOptionsOverrides.code, source: true },\n schemas,\n };\n const ajv = createAjvInstance(additionalMetaSchemas, customFormats, compileOptions, ajvFormatOptions, AjvClass);\n\n const moduleCode = standaloneCode(ajv);\n console.log(`writing ${output}`);\n fs.writeFileSync(output, moduleCode);\n}\n"],"names":["schema","output","options","console","log","schemaMaps","schemaParser","schemas","Object","values","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","compileOptions","code","lines","source","ajv","createAjvInstance","moduleCode","standaloneCode","fs","writeFileSync"],"mappings":"0WAkBc,SACZA,EACAC,EACAC,EAAsC,CAAA,GAEtCC,QAAQC,IAAI,sBACZ,MAAMC,EAAaC,eAAaN,GAC1BO,EAAUC,OAAOC,OAAOJ,IAExBK,sBAAEA,EAAqBC,cAAEA,EAAaC,oBAAEA,EAAsB,CAAE,EAAAC,iBAAEA,EAAgBC,SAAEA,GAAaZ,EAEjGa,EAAiB,IAClBH,EACHI,KAAM,CAAEC,OAAO,KAASL,EAAoBI,KAAME,QAAQ,GAC1DX,WAEIY,EAAMC,EAAAA,kBAAkBV,EAAuBC,EAAeI,EAAgBF,EAAkBC,GAEhGO,EAAaC,UAAeH,GAClChB,QAAQC,eAAeH,KACvBsB,EAAAA,QAAGC,cAAcvB,EAAQoB,EAC3B"}
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("ajv"),a=require("ajv-formats"),r=require("lodash/isObject"),t=require("@rjsf/utils");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=s(e),o=s(a),l=s(r);const u={allErrors:!0,multipleOfPrecision:8,strict:!1,verbose:!0},i=/^(#?([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*\)))$/,n=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;exports.createAjvInstance=function(e,a,r={},s,c=d.default){const b=new c({...u,...r});return s?o.default(b,s):!1!==s&&o.default(b),b.addFormat("data-url",n),b.addFormat("color",i),b.addKeyword(t.ADDITIONAL_PROPERTY_FLAG),b.addKeyword(t.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(e)&&b.addMetaSchema(e),l.default(a)&&Object.keys(a).forEach((e=>{b.addFormat(e,a[e])})),b};
2
+ //# sourceMappingURL=createAjvInstance-33d73c95.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createAjvInstance-0cd8cfba.js","sources":["../src/createAjvInstance.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"],"names":["AJV_CONFIG","allErrors","multipleOfPrecision","strict","verbose","COLOR_FORMAT_REGEX","DATA_URL_FORMAT_REGEX","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"],"mappings":"sbAOO,IAAMA,EAAsB,CACjCC,WAAW,EACXC,oBAAqB,EACrBC,QAAQ,EACRC,SAAS,GAEEC,EACX,6YACWC,EAAwB,kRAiBb,SACtBC,EACAC,EACAC,EACAC,EACAC,YAFAF,IAAAA,EAAyE,CAAA,YAEzEE,IAAAA,EAAuBC,EAAAA,SAEvB,IAAMC,EAAM,IAAIF,EAAQG,EAAA,CAAA,EAAMd,EAAeS,IA2B7C,OA1BIC,EACFK,UAAWF,EAAKH,IACc,IAArBA,GACTK,EAAU,QAACF,GAIbA,EAAIG,UAAU,WAAYV,GAC1BO,EAAIG,UAAU,QAASX,GAGvBQ,EAAII,WAAWC,EAAAA,0BACfL,EAAII,WAAWE,EAAAA,gCAGXC,MAAMC,QAAQd,IAChBM,EAAIS,cAAcf,GAIhBgB,EAAAA,QAASf,IACXgB,OAAOC,KAAKjB,GAAekB,SAAQ,SAACC,GAClCd,EAAIG,UAAUW,EAAYnB,EAAcmB,GAC1C,IAGKd,CACT"}
1
+ {"version":3,"file":"createAjvInstance-33d73c95.js","sources":["../src/createAjvInstance.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"],"names":["AJV_CONFIG","allErrors","multipleOfPrecision","strict","verbose","COLOR_FORMAT_REGEX","DATA_URL_FORMAT_REGEX","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","ajv","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName"],"mappings":"kNAOO,MAAMA,EAAsB,CACjCC,WAAW,EACXC,oBAAqB,EACrBC,QAAQ,EACRC,SAAS,GAEEC,EACX,6YACWC,EAAwB,sFAiBb,SACtBC,EACAC,EACAC,EAAyE,CAAA,EACzEC,EACAC,EAAuBC,WAEvB,MAAMC,EAAM,IAAIF,EAAS,IAAKX,KAAeS,IA2B7C,OA1BIC,EACFI,UAAWD,EAAKH,IACc,IAArBA,GACTI,EAAU,QAACD,GAIbA,EAAIE,UAAU,WAAYT,GAC1BO,EAAIE,UAAU,QAASV,GAGvBQ,EAAIG,WAAWC,EAAAA,0BACfJ,EAAIG,WAAWE,EAAAA,gCAGXC,MAAMC,QAAQb,IAChBM,EAAIQ,cAAcd,GAIhBe,EAAAA,QAASd,IACXe,OAAOC,KAAKhB,GAAeiB,SAASC,IAClCb,EAAIE,UAAUW,EAAYlB,EAAckB,GAAY,IAIjDb,CACT"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var utils = require('@rjsf/utils');
6
- var createAjvInstance = require('./createAjvInstance-0cd8cfba.js');
6
+ var createAjvInstance = require('./createAjvInstance-33d73c95.js');
7
7
  var get = require('lodash/get');
8
8
  var isEqual = require('lodash/isEqual');
9
9
  require('ajv');
@@ -15,60 +15,59 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
15
15
  var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
16
16
  var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
17
17
 
18
- var _excluded = ["instancePath", "keyword", "params", "schemaPath", "parentSchema"];
19
18
  /** Transforming the error output from ajv to format used by @rjsf/utils.
20
19
  * At some point, components should be updated to support ajv.
21
20
  *
22
21
  * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`
23
22
  * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
24
23
  */
25
- function transformRJSFValidationErrors(errors, uiSchema) {
26
- if (errors === void 0) {
27
- errors = [];
28
- }
29
- return errors.map(function (e) {
30
- var instancePath = e.instancePath,
31
- keyword = e.keyword,
32
- params = e.params,
33
- schemaPath = e.schemaPath,
34
- parentSchema = e.parentSchema,
35
- rest = createAjvInstance._objectWithoutPropertiesLoose(e, _excluded);
36
- var _rest$message = rest.message,
37
- message = _rest$message === void 0 ? '' : _rest$message;
38
- var property = instancePath.replace(/\//g, '.');
39
- var stack = (property + " " + message).trim();
24
+ function transformRJSFValidationErrors(errors = [], uiSchema) {
25
+ return errors.map(e => {
26
+ const {
27
+ instancePath,
28
+ keyword,
29
+ params,
30
+ schemaPath,
31
+ parentSchema,
32
+ ...rest
33
+ } = e;
34
+ let {
35
+ message = ''
36
+ } = rest;
37
+ let property = instancePath.replace(/\//g, '.');
38
+ let stack = `${property} ${message}`.trim();
40
39
  if ('missingProperty' in params) {
41
- property = property ? property + "." + params.missingProperty : params.missingProperty;
42
- var currentProperty = params.missingProperty;
43
- var uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, "" + property.replace(/^\./, ''))).title;
40
+ property = property ? `${property}.${params.missingProperty}` : params.missingProperty;
41
+ const currentProperty = params.missingProperty;
42
+ const uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, `${property.replace(/^\./, '')}`)).title;
44
43
  if (uiSchemaTitle) {
45
44
  message = message.replace(currentProperty, uiSchemaTitle);
46
45
  } else {
47
- var parentSchemaTitle = get__default["default"](parentSchema, [utils.PROPERTIES_KEY, currentProperty, 'title']);
46
+ const parentSchemaTitle = get__default["default"](parentSchema, [utils.PROPERTIES_KEY, currentProperty, 'title']);
48
47
  if (parentSchemaTitle) {
49
48
  message = message.replace(currentProperty, parentSchemaTitle);
50
49
  }
51
50
  }
52
51
  stack = message;
53
52
  } else {
54
- var _uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, "" + property.replace(/^\./, ''))).title;
55
- if (_uiSchemaTitle) {
56
- stack = ("'" + _uiSchemaTitle + "' " + message).trim();
53
+ const uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, `${property.replace(/^\./, '')}`)).title;
54
+ if (uiSchemaTitle) {
55
+ stack = `'${uiSchemaTitle}' ${message}`.trim();
57
56
  } else {
58
- var _parentSchemaTitle = parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.title;
59
- if (_parentSchemaTitle) {
60
- stack = ("'" + _parentSchemaTitle + "' " + message).trim();
57
+ const parentSchemaTitle = parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.title;
58
+ if (parentSchemaTitle) {
59
+ stack = `'${parentSchemaTitle}' ${message}`.trim();
61
60
  }
62
61
  }
63
62
  }
64
63
  // put data in expected format
65
64
  return {
66
65
  name: keyword,
67
- property: property,
68
- message: message,
69
- params: params,
70
- stack: stack,
71
- schemaPath: schemaPath
66
+ property,
67
+ message,
68
+ params,
69
+ stack,
70
+ schemaPath
72
71
  };
73
72
  });
74
73
  }
@@ -86,49 +85,52 @@ function transformRJSFValidationErrors(errors, uiSchema) {
86
85
  * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
87
86
  */
88
87
  function processRawValidationErrors(validator, rawErrors, formData, schema, customValidate, transformErrors, uiSchema) {
89
- var invalidSchemaError = rawErrors.validationError;
90
- var errors = transformRJSFValidationErrors(rawErrors.errors, uiSchema);
88
+ const {
89
+ validationError: invalidSchemaError
90
+ } = rawErrors;
91
+ let errors = transformRJSFValidationErrors(rawErrors.errors, uiSchema);
91
92
  if (invalidSchemaError) {
92
- errors = [].concat(errors, [{
93
+ errors = [...errors, {
93
94
  stack: invalidSchemaError.message
94
- }]);
95
+ }];
95
96
  }
96
97
  if (typeof transformErrors === 'function') {
97
98
  errors = transformErrors(errors, uiSchema);
98
99
  }
99
- var errorSchema = utils.toErrorSchema(errors);
100
+ let errorSchema = utils.toErrorSchema(errors);
100
101
  if (invalidSchemaError) {
101
- errorSchema = createAjvInstance._extends({}, errorSchema, {
102
+ errorSchema = {
103
+ ...errorSchema,
102
104
  $schema: {
103
105
  __errors: [invalidSchemaError.message]
104
106
  }
105
- });
107
+ };
106
108
  }
107
109
  if (typeof customValidate !== 'function') {
108
110
  return {
109
- errors: errors,
110
- errorSchema: errorSchema
111
+ errors,
112
+ errorSchema
111
113
  };
112
114
  }
113
115
  // Include form data with undefined values, which is required for custom validation.
114
- var newFormData = utils.getDefaultFormState(validator, schema, formData, schema, true);
115
- var errorHandler = customValidate(newFormData, utils.createErrorHandler(newFormData), uiSchema);
116
- var userErrorSchema = utils.unwrapErrorHandler(errorHandler);
116
+ const newFormData = utils.getDefaultFormState(validator, schema, formData, schema, true);
117
+ const errorHandler = customValidate(newFormData, utils.createErrorHandler(newFormData), uiSchema);
118
+ const userErrorSchema = utils.unwrapErrorHandler(errorHandler);
117
119
  return utils.validationDataMerge({
118
- errors: errors,
119
- errorSchema: errorSchema
120
+ errors,
121
+ errorSchema
120
122
  }, userErrorSchema);
121
123
  }
122
124
 
123
125
  /** `ValidatorType` implementation that uses the AJV 8 validation mechanism.
124
126
  */
125
- var AJV8Validator = /*#__PURE__*/function () {
127
+ class AJV8Validator {
126
128
  /** Constructs an `AJV8Validator` instance using the `options`
127
129
  *
128
130
  * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance
129
131
  * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s
130
132
  */
131
- function AJV8Validator(options, localizer) {
133
+ constructor(options, localizer) {
132
134
  /** The AJV instance to use for all validations
133
135
  *
134
136
  * @private
@@ -139,11 +141,13 @@ var AJV8Validator = /*#__PURE__*/function () {
139
141
  * @private
140
142
  */
141
143
  this.localizer = void 0;
142
- var additionalMetaSchemas = options.additionalMetaSchemas,
143
- customFormats = options.customFormats,
144
- ajvOptionsOverrides = options.ajvOptionsOverrides,
145
- ajvFormatOptions = options.ajvFormatOptions,
146
- AjvClass = options.AjvClass;
144
+ const {
145
+ additionalMetaSchemas,
146
+ customFormats,
147
+ ajvOptionsOverrides,
148
+ ajvFormatOptions,
149
+ AjvClass
150
+ } = options;
147
151
  this.ajv = createAjvInstance.createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);
148
152
  this.localizer = localizer;
149
153
  }
@@ -154,11 +158,7 @@ var AJV8Validator = /*#__PURE__*/function () {
154
158
  * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in
155
159
  * the next major release.
156
160
  */
157
- var _proto = AJV8Validator.prototype;
158
- _proto.toErrorList = function toErrorList(errorSchema, fieldPath) {
159
- if (fieldPath === void 0) {
160
- fieldPath = [];
161
- }
161
+ toErrorList(errorSchema, fieldPath = []) {
162
162
  return utils.toErrorList(errorSchema, fieldPath);
163
163
  }
164
164
  /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use
@@ -166,10 +166,10 @@ var AJV8Validator = /*#__PURE__*/function () {
166
166
  *
167
167
  * @param schema - The schema against which to validate the form data * @param schema
168
168
  * @param formData - The form data to validate
169
- */;
170
- _proto.rawValidation = function rawValidation(schema, formData) {
171
- var compilationError = undefined;
172
- var compiledValidator;
169
+ */
170
+ rawValidation(schema, formData) {
171
+ let compilationError = undefined;
172
+ let compiledValidator;
173
173
  if (schema[utils.ID_KEY]) {
174
174
  compiledValidator = this.ajv.getSchema(schema[utils.ID_KEY]);
175
175
  }
@@ -181,7 +181,7 @@ var AJV8Validator = /*#__PURE__*/function () {
181
181
  } catch (err) {
182
182
  compilationError = err;
183
183
  }
184
- var errors;
184
+ let errors;
185
185
  if (compiledValidator) {
186
186
  if (typeof this.localizer === 'function') {
187
187
  this.localizer(compiledValidator.errors);
@@ -205,9 +205,9 @@ var AJV8Validator = /*#__PURE__*/function () {
205
205
  * @param [customValidate] - An optional function that is used to perform custom validation
206
206
  * @param [transformErrors] - An optional function that is used to transform errors after AJV validation
207
207
  * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
208
- */;
209
- _proto.validateFormData = function validateFormData(formData, schema, customValidate, transformErrors, uiSchema) {
210
- var rawErrors = this.rawValidation(schema, formData);
208
+ */
209
+ validateFormData(formData, schema, customValidate, transformErrors, uiSchema) {
210
+ const rawErrors = this.rawValidation(schema, formData);
211
211
  return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);
212
212
  }
213
213
  /** Validates data against a schema, returning true if the data is valid, or
@@ -217,12 +217,10 @@ var AJV8Validator = /*#__PURE__*/function () {
217
217
  * @param schema - The schema against which to validate the form data
218
218
  * @param formData - The form data to validate
219
219
  * @param rootSchema - The root schema used to provide $ref resolutions
220
- */;
221
- _proto.isValid = function isValid(schema, formData, rootSchema) {
222
- var _rootSchema$ID_KEY;
223
- var rootSchemaId = (_rootSchema$ID_KEY = rootSchema[utils.ID_KEY]) != null ? _rootSchema$ID_KEY : utils.ROOT_SCHEMA_PREFIX;
220
+ */
221
+ isValid(schema, formData, rootSchema) {
222
+ const rootSchemaId = rootSchema[utils.ID_KEY] ?? utils.ROOT_SCHEMA_PREFIX;
224
223
  try {
225
- var _schemaWithIdRefPrefi;
226
224
  // add the rootSchema ROOT_SCHEMA_PREFIX as id.
227
225
  // then rewrite the schema ref's to point to the rootSchema
228
226
  // this accounts for the case where schema have references to models
@@ -230,9 +228,9 @@ var AJV8Validator = /*#__PURE__*/function () {
230
228
  if (this.ajv.getSchema(rootSchemaId) === undefined) {
231
229
  this.ajv.addSchema(rootSchema, rootSchemaId);
232
230
  }
233
- var schemaWithIdRefPrefix = utils.withIdRefPrefix(schema);
234
- var schemaId = (_schemaWithIdRefPrefi = schemaWithIdRefPrefix[utils.ID_KEY]) != null ? _schemaWithIdRefPrefi : utils.hashForSchema(schemaWithIdRefPrefix);
235
- var compiledValidator;
231
+ const schemaWithIdRefPrefix = utils.withIdRefPrefix(schema);
232
+ const schemaId = schemaWithIdRefPrefix[utils.ID_KEY] ?? utils.hashForSchema(schemaWithIdRefPrefix);
233
+ let compiledValidator;
236
234
  compiledValidator = this.ajv.getSchema(schemaId);
237
235
  if (compiledValidator === undefined) {
238
236
  // Add schema by an explicit ID so it can be fetched later
@@ -240,7 +238,7 @@ var AJV8Validator = /*#__PURE__*/function () {
240
238
  // https://ajv.js.org/guide/managing-schemas.html#pre-adding-all-schemas-vs-adding-on-demand
241
239
  compiledValidator = this.ajv.addSchema(schemaWithIdRefPrefix, schemaId).getSchema(schemaId) || this.ajv.compile(schemaWithIdRefPrefix);
242
240
  }
243
- var result = compiledValidator(formData);
241
+ const result = compiledValidator(formData);
244
242
  return result;
245
243
  } catch (e) {
246
244
  console.warn('Error encountered compiling schema:', e);
@@ -250,9 +248,8 @@ var AJV8Validator = /*#__PURE__*/function () {
250
248
  // make sure we remove the rootSchema from the global ajv instance
251
249
  this.ajv.removeSchema(rootSchemaId);
252
250
  }
253
- };
254
- return AJV8Validator;
255
- }();
251
+ }
252
+ }
256
253
 
257
254
  /** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if
258
255
  * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV
@@ -262,17 +259,14 @@ var AJV8Validator = /*#__PURE__*/function () {
262
259
  * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s
263
260
  * @returns - The custom validator implementation resulting from the set of parameters provided
264
261
  */
265
- function customizeValidator(options, localizer) {
266
- if (options === void 0) {
267
- options = {};
268
- }
262
+ function customizeValidator(options = {}, localizer) {
269
263
  return new AJV8Validator(options, localizer);
270
264
  }
271
265
 
272
266
  /** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the
273
267
  * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.
274
268
  */
275
- var AJV8PrecompiledValidator = /*#__PURE__*/function () {
269
+ class AJV8PrecompiledValidator {
276
270
  /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`
277
271
  *
278
272
  * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function
@@ -280,7 +274,7 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
280
274
  * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s
281
275
  * @throws - Error when the base schema of the precompiled validator does not have a matching validator function
282
276
  */
283
- function AJV8PrecompiledValidator(validateFns, rootSchema, localizer) {
277
+ constructor(validateFns, rootSchema, localizer) {
284
278
  /** The root schema object used to construct this validator
285
279
  *
286
280
  * @private
@@ -318,12 +312,11 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
318
312
  * @param schema - The schema for which a precompiled validator function is desired
319
313
  * @returns - The precompiled validator function associated with this schema
320
314
  */
321
- var _proto = AJV8PrecompiledValidator.prototype;
322
- _proto.getValidator = function getValidator(schema) {
323
- var key = get__default["default"](schema, utils.ID_KEY) || utils.hashForSchema(schema);
324
- var validator = this.validateFns[key];
315
+ getValidator(schema) {
316
+ const key = get__default["default"](schema, utils.ID_KEY) || utils.hashForSchema(schema);
317
+ const validator = this.validateFns[key];
325
318
  if (!validator) {
326
- throw new Error("No precompiled validator function was found for the given schema for \"" + key + "\"");
319
+ throw new Error(`No precompiled validator function was found for the given schema for "${key}"`);
327
320
  }
328
321
  return validator;
329
322
  }
@@ -333,11 +326,8 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
333
326
  * @param [fieldPath=[]] - The current field path, defaults to [] if not specified
334
327
  * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in
335
328
  * the next major release.
336
- */;
337
- _proto.toErrorList = function toErrorList(errorSchema, fieldPath) {
338
- if (fieldPath === void 0) {
339
- fieldPath = [];
340
- }
329
+ */
330
+ toErrorList(errorSchema, fieldPath = []) {
341
331
  return utils.toErrorList(errorSchema, fieldPath);
342
332
  }
343
333
  /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use
@@ -346,8 +336,8 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
346
336
  * @param schema - The schema against which to validate the form data * @param schema
347
337
  * @param formData - The form data to validate
348
338
  * @throws - Error when the schema provided does not match the base schema of the precompiled validator
349
- */;
350
- _proto.rawValidation = function rawValidation(schema, formData) {
339
+ */
340
+ rawValidation(schema, formData) {
351
341
  if (!isEqual__default["default"](schema, this.resolvedRootSchema)) {
352
342
  throw new Error('The schema associated with the precompiled schema differs from the schema provided for validation');
353
343
  }
@@ -355,7 +345,7 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
355
345
  if (typeof this.localizer === 'function') {
356
346
  this.localizer(this.mainValidator.errors);
357
347
  }
358
- var errors = this.mainValidator.errors || undefined;
348
+ const errors = this.mainValidator.errors || undefined;
359
349
  // Clear errors to prevent persistent errors, see #1104
360
350
  this.mainValidator.errors = null;
361
351
  return {
@@ -372,9 +362,9 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
372
362
  * @param [customValidate] - An optional function that is used to perform custom validation
373
363
  * @param [transformErrors] - An optional function that is used to transform errors after AJV validation
374
364
  * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
375
- */;
376
- _proto.validateFormData = function validateFormData(formData, schema, customValidate, transformErrors, uiSchema) {
377
- var rawErrors = this.rawValidation(schema, formData);
365
+ */
366
+ validateFormData(formData, schema, customValidate, transformErrors, uiSchema) {
367
+ const rawErrors = this.rawValidation(schema, formData);
378
368
  return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);
379
369
  }
380
370
  /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is
@@ -386,19 +376,18 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
386
376
  * @returns - true if the formData validates against the schema, false otherwise
387
377
  * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there
388
378
  * isn't a precompiled validator function associated with the schema
389
- */;
390
- _proto.isValid = function isValid(schema, formData, rootSchema) {
379
+ */
380
+ isValid(schema, formData, rootSchema) {
391
381
  if (!isEqual__default["default"](rootSchema, this.rootSchema)) {
392
382
  throw new Error('The schema associated with the precompiled validator differs from the rootSchema provided for validation');
393
383
  }
394
384
  if (get__default["default"](schema, utils.ID_KEY) === utils.JUNK_OPTION_ID) {
395
385
  return false;
396
386
  }
397
- var validator = this.getValidator(schema);
387
+ const validator = this.getValidator(schema);
398
388
  return validator(formData);
399
- };
400
- return AJV8PrecompiledValidator;
401
- }();
389
+ }
390
+ }
402
391
 
403
392
  /** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`
404
393
  * is provided, it is used to translate the messages generated by the underlying AJV validation.