Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rjsf/validator-ajv8

Package Overview
Dependencies
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rjsf/validator-ajv8 - npm Package Compare versions

Comparing version 5.0.0-beta.13 to 5.0.0-beta.14

6

dist/validator-ajv8.cjs.development.js

@@ -323,5 +323,3 @@ 'use strict';

validateFormData(formData, schema, customValidate, transformErrors) {
// Include form data with undefined values, which is required for validation.
const newFormData = utils.getDefaultFormState(this, schema, formData, schema, true);
const rawErrors = this.rawValidation(schema, newFormData);
const rawErrors = this.rawValidation(schema, formData);
const {

@@ -354,2 +352,4 @@ validationError: invalidSchemaError

}
// Include form data with undefined values, which is required for custom validation.
const newFormData = utils.getDefaultFormState(this, schema, formData, schema, true);
const errorHandler = customValidate(newFormData, this.createErrorHandler(newFormData));

@@ -356,0 +356,0 @@ const userErrorSchema = this.unwrapErrorHandler(errorHandler);

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("lodash/toPath"),e=require("lodash/isObject"),t=require("lodash/clone"),a=require("@rjsf/utils"),o=require("ajv8"),s=require("ajv-formats");function i(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var n=i(r),d=i(e),c=i(t),l=i(o),h=i(s);const u={allErrors:!0,multipleOfPrecision:8,strict:!1},f=/^(#?([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*\)))$/,m=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;class v{constructor(r,e){this.ajv=void 0,this.localizer=void 0;const{additionalMetaSchemas:t,customFormats:o,ajvOptionsOverrides:s,ajvFormatOptions:i,AjvClass:n}=r;this.ajv=function(r,e,t,o,s){void 0===t&&(t={}),void 0===s&&(s=l.default);const i=new s({...u,...t});return o?h.default(i,o):!1!==o&&h.default(i),i.addFormat("data-url",m),i.addFormat("color",f),i.addKeyword(a.ADDITIONAL_PROPERTY_FLAG),i.addKeyword(a.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&i.addMetaSchema(r),d.default(e)&&Object.keys(e).forEach((r=>{i.addFormat(r,e[r])})),i}(t,o,s,i,n),this.localizer=e}toErrorSchema(r){return r.length?r.reduce(((r,e)=>{const{property:t,message:a}=e,o=n.default(t);let s=r;o.length>0&&""===o[0]&&o.splice(0,1);for(const r of o.slice(0))r in s||(s[r]={}),s=s[r];return Array.isArray(s.__errors)?s.__errors=s.__errors.concat(a):a&&(s.__errors=[a]),r}),{}):{}}toErrorList(r,e){if(void 0===e&&(e=[]),!r)return[];let t=[];return a.ERRORS_KEY in r&&(t=t.concat(r.__errors.map((r=>{const t=`.${e.join(".")}`;return{property:t,message:r,stack:`${t} ${r}`}})))),Object.keys(r).reduce(((t,o)=>(o!==a.ERRORS_KEY&&(t=t.concat(this.toErrorList(r[o],[...e,o]))),t)),t)}createErrorHandler(r){const e={__errors:[],addError(r){this.__errors.push(r)}};if(Array.isArray(r))return r.reduce(((r,e,t)=>({...r,[t]:this.createErrorHandler(e)})),e);if(d.default(r)){const t=r;return Object.keys(t).reduce(((r,e)=>({...r,[e]:this.createErrorHandler(t[e])})),e)}return e}unwrapErrorHandler(r){return Object.keys(r).reduce(((e,t)=>"addError"===t?e:t===a.ERRORS_KEY?{...e,[t]:r[t]}:{...e,[t]:this.unwrapErrorHandler(r[t])}),{})}transformRJSFValidationErrors(r){return void 0===r&&(r=[]),r.map((r=>{const{instancePath:e,keyword:t,message:a,params:o,schemaPath:s}=r,i=e.replace(/\//g,".");return{name:t,property:i,message:a,params:o,stack:`${i} ${a}`.trim(),schemaPath:s}}))}rawValidation(r,e){let t,a,o;r.$id&&(a=this.ajv.getSchema(r.$id));try{void 0===a&&(a=this.ajv.compile(r)),a(e)}catch(r){t=r}return a&&("function"==typeof this.localizer&&this.localizer(a.errors),o=a.errors||void 0,a.errors=null),{errors:o,validationError:t}}validateFormData(r,e,t,o){const s=a.getDefaultFormState(this,e,r,e,!0),i=this.rawValidation(e,s),{validationError:n}=i;let d=this.transformRJSFValidationErrors(i.errors);n&&(d=[...d,{stack:n.message}]),"function"==typeof o&&(d=o(d));let c=this.toErrorSchema(d);if(n&&(c={...c,$schema:{__errors:[n.message]}}),"function"!=typeof t)return{errors:d,errorSchema:c};const l=t(s,this.createErrorHandler(s)),h=this.unwrapErrorHandler(l);return a.mergeValidationData(this,{errors:d,errorSchema:c},h)}withIdRefPrefixObject(r){for(const e in r){const t=r[e];r[e]=e===a.REF_KEY&&"string"==typeof t&&t.startsWith("#")?"__rjsf_rootSchema"+t:this.withIdRefPrefix(t)}return r}withIdRefPrefixArray(r){for(let e=0;e<r.length;e++)r[e]=this.withIdRefPrefix(r[e]);return r}isValid(r,e,t){const a=t.$id??"__rjsf_rootSchema";try{void 0===this.ajv.getSchema(a)&&this.ajv.addSchema(t,a);const o=this.withIdRefPrefix(r);let s;return o.$id&&(s=this.ajv.getSchema(o.$id)),void 0===s&&(s=this.ajv.compile(o)),s(e)}catch(r){return console.warn("Error encountered compiling schema:",r),!1}finally{this.ajv.removeSchema(a)}}withIdRefPrefix(r){return Array.isArray(r)?this.withIdRefPrefixArray([...r]):d.default(r)?this.withIdRefPrefixObject(c.default(r)):r}}function p(r,e){return void 0===r&&(r={}),new v(r,e)}var _=p();exports.customizeValidator=p,exports.default=_;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("lodash/toPath"),e=require("lodash/isObject"),t=require("lodash/clone"),a=require("@rjsf/utils"),o=require("ajv8"),s=require("ajv-formats");function i(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var n=i(r),d=i(e),c=i(t),l=i(o),h=i(s);const u={allErrors:!0,multipleOfPrecision:8,strict:!1},f=/^(#?([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*\)))$/,m=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;class v{constructor(r,e){this.ajv=void 0,this.localizer=void 0;const{additionalMetaSchemas:t,customFormats:o,ajvOptionsOverrides:s,ajvFormatOptions:i,AjvClass:n}=r;this.ajv=function(r,e,t,o,s){void 0===t&&(t={}),void 0===s&&(s=l.default);const i=new s({...u,...t});return o?h.default(i,o):!1!==o&&h.default(i),i.addFormat("data-url",m),i.addFormat("color",f),i.addKeyword(a.ADDITIONAL_PROPERTY_FLAG),i.addKeyword(a.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&i.addMetaSchema(r),d.default(e)&&Object.keys(e).forEach((r=>{i.addFormat(r,e[r])})),i}(t,o,s,i,n),this.localizer=e}toErrorSchema(r){return r.length?r.reduce(((r,e)=>{const{property:t,message:a}=e,o=n.default(t);let s=r;o.length>0&&""===o[0]&&o.splice(0,1);for(const r of o.slice(0))r in s||(s[r]={}),s=s[r];return Array.isArray(s.__errors)?s.__errors=s.__errors.concat(a):a&&(s.__errors=[a]),r}),{}):{}}toErrorList(r,e){if(void 0===e&&(e=[]),!r)return[];let t=[];return a.ERRORS_KEY in r&&(t=t.concat(r.__errors.map((r=>{const t=`.${e.join(".")}`;return{property:t,message:r,stack:`${t} ${r}`}})))),Object.keys(r).reduce(((t,o)=>(o!==a.ERRORS_KEY&&(t=t.concat(this.toErrorList(r[o],[...e,o]))),t)),t)}createErrorHandler(r){const e={__errors:[],addError(r){this.__errors.push(r)}};if(Array.isArray(r))return r.reduce(((r,e,t)=>({...r,[t]:this.createErrorHandler(e)})),e);if(d.default(r)){const t=r;return Object.keys(t).reduce(((r,e)=>({...r,[e]:this.createErrorHandler(t[e])})),e)}return e}unwrapErrorHandler(r){return Object.keys(r).reduce(((e,t)=>"addError"===t?e:t===a.ERRORS_KEY?{...e,[t]:r[t]}:{...e,[t]:this.unwrapErrorHandler(r[t])}),{})}transformRJSFValidationErrors(r){return void 0===r&&(r=[]),r.map((r=>{const{instancePath:e,keyword:t,message:a,params:o,schemaPath:s}=r,i=e.replace(/\//g,".");return{name:t,property:i,message:a,params:o,stack:`${i} ${a}`.trim(),schemaPath:s}}))}rawValidation(r,e){let t,a,o;r.$id&&(a=this.ajv.getSchema(r.$id));try{void 0===a&&(a=this.ajv.compile(r)),a(e)}catch(r){t=r}return a&&("function"==typeof this.localizer&&this.localizer(a.errors),o=a.errors||void 0,a.errors=null),{errors:o,validationError:t}}validateFormData(r,e,t,o){const s=this.rawValidation(e,r),{validationError:i}=s;let n=this.transformRJSFValidationErrors(s.errors);i&&(n=[...n,{stack:i.message}]),"function"==typeof o&&(n=o(n));let d=this.toErrorSchema(n);if(i&&(d={...d,$schema:{__errors:[i.message]}}),"function"!=typeof t)return{errors:n,errorSchema:d};const c=a.getDefaultFormState(this,e,r,e,!0),l=t(c,this.createErrorHandler(c)),h=this.unwrapErrorHandler(l);return a.mergeValidationData(this,{errors:n,errorSchema:d},h)}withIdRefPrefixObject(r){for(const e in r){const t=r[e];r[e]=e===a.REF_KEY&&"string"==typeof t&&t.startsWith("#")?"__rjsf_rootSchema"+t:this.withIdRefPrefix(t)}return r}withIdRefPrefixArray(r){for(let e=0;e<r.length;e++)r[e]=this.withIdRefPrefix(r[e]);return r}isValid(r,e,t){const a=t.$id??"__rjsf_rootSchema";try{void 0===this.ajv.getSchema(a)&&this.ajv.addSchema(t,a);const o=this.withIdRefPrefix(r);let s;return o.$id&&(s=this.ajv.getSchema(o.$id)),void 0===s&&(s=this.ajv.compile(o)),s(e)}catch(r){return console.warn("Error encountered compiling schema:",r),!1}finally{this.ajv.removeSchema(a)}}withIdRefPrefix(r){return Array.isArray(r)?this.withIdRefPrefixArray([...r]):d.default(r)?this.withIdRefPrefixObject(c.default(r)):r}}function p(r,e){return void 0===r&&(r={}),new v(r,e)}var _=p();exports.customizeValidator=p,exports.default=_;
//# sourceMappingURL=validator-ajv8.cjs.production.min.js.map

@@ -311,5 +311,3 @@ import toPath from 'lodash-es/toPath';

validateFormData(formData, schema, customValidate, transformErrors) {
// Include form data with undefined values, which is required for validation.
const newFormData = getDefaultFormState(this, schema, formData, schema, true);
const rawErrors = this.rawValidation(schema, newFormData);
const rawErrors = this.rawValidation(schema, formData);
const {

@@ -342,2 +340,4 @@ validationError: invalidSchemaError

}
// Include form data with undefined values, which is required for custom validation.
const newFormData = getDefaultFormState(this, schema, formData, schema, true);
const errorHandler = customValidate(newFormData, this.createErrorHandler(newFormData));

@@ -344,0 +344,0 @@ const userErrorSchema = this.unwrapErrorHandler(errorHandler);

@@ -318,5 +318,3 @@ (function (global, factory) {

validateFormData(formData, schema, customValidate, transformErrors) {
// Include form data with undefined values, which is required for validation.
const newFormData = utils.getDefaultFormState(this, schema, formData, schema, true);
const rawErrors = this.rawValidation(schema, newFormData);
const rawErrors = this.rawValidation(schema, formData);
const {

@@ -349,2 +347,4 @@ validationError: invalidSchemaError

}
// Include form data with undefined values, which is required for custom validation.
const newFormData = utils.getDefaultFormState(this, schema, formData, schema, true);
const errorHandler = customValidate(newFormData, this.createErrorHandler(newFormData));

@@ -351,0 +351,0 @@ const userErrorSchema = this.unwrapErrorHandler(errorHandler);

@@ -1,2 +0,2 @@

!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("lodash-es/toPath"),require("lodash-es/isObject"),require("lodash-es/clone"),require("@rjsf/utils"),require("ajv8"),require("ajv-formats")):"function"==typeof define&&define.amd?define(["exports","lodash-es/toPath","lodash-es/isObject","lodash-es/clone","@rjsf/utils","ajv8","ajv-formats"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self)["@rjsf/validator-ajv8"]={},r.toPath,r.isObject,r.clone,r.utils,r.Ajv,r.addFormats)}(this,(function(r,e,t,a,o,s,i){"use strict";function n(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var d=n(e),c=n(t),l=n(a),h=n(s),u=n(i);const f={allErrors:!0,multipleOfPrecision:8,strict:!1},m=/^(#?([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*\)))$/,v=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/,p="__rjsf_rootSchema";class y{constructor(r,e){this.ajv=void 0,this.localizer=void 0;const{additionalMetaSchemas:t,customFormats:a,ajvOptionsOverrides:s,ajvFormatOptions:i,AjvClass:n}=r;this.ajv=function(r,e,t,a,s){void 0===t&&(t={}),void 0===s&&(s=h.default);const i=new s({...f,...t});return a?u.default(i,a):!1!==a&&u.default(i),i.addFormat("data-url",v),i.addFormat("color",m),i.addKeyword(o.ADDITIONAL_PROPERTY_FLAG),i.addKeyword(o.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&i.addMetaSchema(r),c.default(e)&&Object.keys(e).forEach((r=>{i.addFormat(r,e[r])})),i}(t,a,s,i,n),this.localizer=e}toErrorSchema(r){return r.length?r.reduce(((r,e)=>{const{property:t,message:a}=e,o=d.default(t);let s=r;o.length>0&&""===o[0]&&o.splice(0,1);for(const r of o.slice(0))r in s||(s[r]={}),s=s[r];return Array.isArray(s.__errors)?s.__errors=s.__errors.concat(a):a&&(s.__errors=[a]),r}),{}):{}}toErrorList(r,e){if(void 0===e&&(e=[]),!r)return[];let t=[];return o.ERRORS_KEY in r&&(t=t.concat(r.__errors.map((r=>{const t=`.${e.join(".")}`;return{property:t,message:r,stack:`${t} ${r}`}})))),Object.keys(r).reduce(((t,a)=>(a!==o.ERRORS_KEY&&(t=t.concat(this.toErrorList(r[a],[...e,a]))),t)),t)}createErrorHandler(r){const e={__errors:[],addError(r){this.__errors.push(r)}};if(Array.isArray(r))return r.reduce(((r,e,t)=>({...r,[t]:this.createErrorHandler(e)})),e);if(c.default(r)){const t=r;return Object.keys(t).reduce(((r,e)=>({...r,[e]:this.createErrorHandler(t[e])})),e)}return e}unwrapErrorHandler(r){return Object.keys(r).reduce(((e,t)=>"addError"===t?e:t===o.ERRORS_KEY?{...e,[t]:r[t]}:{...e,[t]:this.unwrapErrorHandler(r[t])}),{})}transformRJSFValidationErrors(r){return void 0===r&&(r=[]),r.map((r=>{const{instancePath:e,keyword:t,message:a,params:o,schemaPath:s}=r,i=e.replace(/\//g,".");return{name:t,property:i,message:a,params:o,stack:`${i} ${a}`.trim(),schemaPath:s}}))}rawValidation(r,e){let t,a,o;r.$id&&(a=this.ajv.getSchema(r.$id));try{void 0===a&&(a=this.ajv.compile(r)),a(e)}catch(r){t=r}return a&&("function"==typeof this.localizer&&this.localizer(a.errors),o=a.errors||void 0,a.errors=null),{errors:o,validationError:t}}validateFormData(r,e,t,a){const s=o.getDefaultFormState(this,e,r,e,!0),i=this.rawValidation(e,s),{validationError:n}=i;let d=this.transformRJSFValidationErrors(i.errors);n&&(d=[...d,{stack:n.message}]),"function"==typeof a&&(d=a(d));let c=this.toErrorSchema(d);if(n&&(c={...c,$schema:{__errors:[n.message]}}),"function"!=typeof t)return{errors:d,errorSchema:c};const l=t(s,this.createErrorHandler(s)),h=this.unwrapErrorHandler(l);return o.mergeValidationData(this,{errors:d,errorSchema:c},h)}withIdRefPrefixObject(r){for(const e in r){const t=r[e];r[e]=e===o.REF_KEY&&"string"==typeof t&&t.startsWith("#")?p+t:this.withIdRefPrefix(t)}return r}withIdRefPrefixArray(r){for(let e=0;e<r.length;e++)r[e]=this.withIdRefPrefix(r[e]);return r}isValid(r,e,t){const a=t.$id??p;try{void 0===this.ajv.getSchema(a)&&this.ajv.addSchema(t,a);const o=this.withIdRefPrefix(r);let s;return o.$id&&(s=this.ajv.getSchema(o.$id)),void 0===s&&(s=this.ajv.compile(o)),s(e)}catch(r){return console.warn("Error encountered compiling schema:",r),!1}finally{this.ajv.removeSchema(a)}}withIdRefPrefix(r){return Array.isArray(r)?this.withIdRefPrefixArray([...r]):c.default(r)?this.withIdRefPrefixObject(l.default(r)):r}}function j(r,e){return void 0===r&&(r={}),new y(r,e)}var E=j();r.customizeValidator=j,r.default=E,Object.defineProperty(r,"__esModule",{value:!0})}));
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("lodash-es/toPath"),require("lodash-es/isObject"),require("lodash-es/clone"),require("@rjsf/utils"),require("ajv8"),require("ajv-formats")):"function"==typeof define&&define.amd?define(["exports","lodash-es/toPath","lodash-es/isObject","lodash-es/clone","@rjsf/utils","ajv8","ajv-formats"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self)["@rjsf/validator-ajv8"]={},r.toPath,r.isObject,r.clone,r.utils,r.Ajv,r.addFormats)}(this,(function(r,e,t,a,o,s,i){"use strict";function n(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var d=n(e),c=n(t),l=n(a),h=n(s),u=n(i);const f={allErrors:!0,multipleOfPrecision:8,strict:!1},m=/^(#?([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*\)))$/,v=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/,p="__rjsf_rootSchema";class y{constructor(r,e){this.ajv=void 0,this.localizer=void 0;const{additionalMetaSchemas:t,customFormats:a,ajvOptionsOverrides:s,ajvFormatOptions:i,AjvClass:n}=r;this.ajv=function(r,e,t,a,s){void 0===t&&(t={}),void 0===s&&(s=h.default);const i=new s({...f,...t});return a?u.default(i,a):!1!==a&&u.default(i),i.addFormat("data-url",v),i.addFormat("color",m),i.addKeyword(o.ADDITIONAL_PROPERTY_FLAG),i.addKeyword(o.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&i.addMetaSchema(r),c.default(e)&&Object.keys(e).forEach((r=>{i.addFormat(r,e[r])})),i}(t,a,s,i,n),this.localizer=e}toErrorSchema(r){return r.length?r.reduce(((r,e)=>{const{property:t,message:a}=e,o=d.default(t);let s=r;o.length>0&&""===o[0]&&o.splice(0,1);for(const r of o.slice(0))r in s||(s[r]={}),s=s[r];return Array.isArray(s.__errors)?s.__errors=s.__errors.concat(a):a&&(s.__errors=[a]),r}),{}):{}}toErrorList(r,e){if(void 0===e&&(e=[]),!r)return[];let t=[];return o.ERRORS_KEY in r&&(t=t.concat(r.__errors.map((r=>{const t=`.${e.join(".")}`;return{property:t,message:r,stack:`${t} ${r}`}})))),Object.keys(r).reduce(((t,a)=>(a!==o.ERRORS_KEY&&(t=t.concat(this.toErrorList(r[a],[...e,a]))),t)),t)}createErrorHandler(r){const e={__errors:[],addError(r){this.__errors.push(r)}};if(Array.isArray(r))return r.reduce(((r,e,t)=>({...r,[t]:this.createErrorHandler(e)})),e);if(c.default(r)){const t=r;return Object.keys(t).reduce(((r,e)=>({...r,[e]:this.createErrorHandler(t[e])})),e)}return e}unwrapErrorHandler(r){return Object.keys(r).reduce(((e,t)=>"addError"===t?e:t===o.ERRORS_KEY?{...e,[t]:r[t]}:{...e,[t]:this.unwrapErrorHandler(r[t])}),{})}transformRJSFValidationErrors(r){return void 0===r&&(r=[]),r.map((r=>{const{instancePath:e,keyword:t,message:a,params:o,schemaPath:s}=r,i=e.replace(/\//g,".");return{name:t,property:i,message:a,params:o,stack:`${i} ${a}`.trim(),schemaPath:s}}))}rawValidation(r,e){let t,a,o;r.$id&&(a=this.ajv.getSchema(r.$id));try{void 0===a&&(a=this.ajv.compile(r)),a(e)}catch(r){t=r}return a&&("function"==typeof this.localizer&&this.localizer(a.errors),o=a.errors||void 0,a.errors=null),{errors:o,validationError:t}}validateFormData(r,e,t,a){const s=this.rawValidation(e,r),{validationError:i}=s;let n=this.transformRJSFValidationErrors(s.errors);i&&(n=[...n,{stack:i.message}]),"function"==typeof a&&(n=a(n));let d=this.toErrorSchema(n);if(i&&(d={...d,$schema:{__errors:[i.message]}}),"function"!=typeof t)return{errors:n,errorSchema:d};const c=o.getDefaultFormState(this,e,r,e,!0),l=t(c,this.createErrorHandler(c)),h=this.unwrapErrorHandler(l);return o.mergeValidationData(this,{errors:n,errorSchema:d},h)}withIdRefPrefixObject(r){for(const e in r){const t=r[e];r[e]=e===o.REF_KEY&&"string"==typeof t&&t.startsWith("#")?p+t:this.withIdRefPrefix(t)}return r}withIdRefPrefixArray(r){for(let e=0;e<r.length;e++)r[e]=this.withIdRefPrefix(r[e]);return r}isValid(r,e,t){const a=t.$id??p;try{void 0===this.ajv.getSchema(a)&&this.ajv.addSchema(t,a);const o=this.withIdRefPrefix(r);let s;return o.$id&&(s=this.ajv.getSchema(o.$id)),void 0===s&&(s=this.ajv.compile(o)),s(e)}catch(r){return console.warn("Error encountered compiling schema:",r),!1}finally{this.ajv.removeSchema(a)}}withIdRefPrefix(r){return Array.isArray(r)?this.withIdRefPrefixArray([...r]):c.default(r)?this.withIdRefPrefixObject(l.default(r)):r}}function j(r,e){return void 0===r&&(r={}),new y(r,e)}var E=j();r.customizeValidator=j,r.default=E,Object.defineProperty(r,"__esModule",{value:!0})}));
//# sourceMappingURL=validator-ajv8.umd.production.min.js.map
{
"name": "@rjsf/validator-ajv8",
"version": "5.0.0-beta.13",
"version": "5.0.0-beta.14",
"main": "dist/index.js",

@@ -45,3 +45,3 @@ "module": "dist/validator-ajv8.esm.js",

"@babel/preset-react": "^7.18.6",
"@rjsf/utils": "^5.0.0-beta.13",
"@rjsf/utils": "^5.0.0-beta.14",
"@types/jest-expect-message": "^1.1.0",

@@ -76,3 +76,3 @@ "@types/json-schema": "^7.0.9",

"license": "Apache-2.0",
"gitHead": "c06ccc2d11f998a3df74d3104e768f3dfeb3212d"
"gitHead": "a0f9a938e4551a42d5c94f8673b13b937279cdc5"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc