Socket
Socket
Sign inDemoInstall

@rjsf/validator-ajv8

Package Overview
Dependencies
Maintainers
2
Versions
76
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.16 to 5.0.0-beta.17

4

dist/index.d.ts
import * as _rjsf_utils from '@rjsf/utils';
import { StrictRJSFSchema, RJSFSchema, FormContextType, ValidatorType } from '@rjsf/utils';
import Ajv, { Options, ErrorObject } from 'ajv8';
import Ajv, { Options, ErrorObject } from 'ajv';
import { FormatsPluginOptions } from 'ajv-formats';

@@ -24,3 +24,3 @@

*/
declare type Localizer = (errors?: null | ErrorObject[]) => void;
type Localizer = (errors?: null | ErrorObject[]) => void;

@@ -27,0 +27,0 @@ /** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if

@@ -9,3 +9,4 @@ 'use strict';

var utils = require('@rjsf/utils');
var Ajv = require('ajv8');
var get = require('lodash/get');
var Ajv = require('ajv');
var addFormats = require('ajv-formats');

@@ -18,2 +19,3 @@

var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);

@@ -36,2 +38,14 @@ var addFormats__default = /*#__PURE__*/_interopDefaultLegacy(addFormats);

}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}

@@ -41,3 +55,4 @@ var AJV_CONFIG = {

multipleOfPrecision: 8,
strict: false
strict: false,
verbose: true
};

@@ -93,2 +108,3 @@ var COLOR_FORMAT_REGEX = /^(#?([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*\)))$/;

var _excluded = ["instancePath", "keyword", "params", "schemaPath", "parentSchema"];
var ROOT_SCHEMA_PREFIX = "__rjsf_rootSchema";

@@ -247,5 +263,5 @@ /** `ValidatorType` implementation that uses the AJV 8 validation mechanism.

* @param errors - The list of AJV errors to convert to `RJSFValidationErrors`
* @private
* @protected
*/;
_proto.transformRJSFValidationErrors = function transformRJSFValidationErrors(errors) {
_proto.transformRJSFValidationErrors = function transformRJSFValidationErrors(errors, uiSchema) {
if (errors === void 0) {

@@ -257,5 +273,8 @@ errors = [];

keyword = e.keyword,
message = e.message,
params = e.params,
schemaPath = e.schemaPath;
schemaPath = e.schemaPath,
parentSchema = e.parentSchema,
rest = _objectWithoutPropertiesLoose(e, _excluded);
var _rest$message = rest.message,
message = _rest$message === void 0 ? "" : _rest$message;
var property = instancePath.replace(/\//g, ".");

@@ -265,3 +284,23 @@ var stack = (property + " " + message).trim();

property = property ? property + "." + params.missingProperty : params.missingProperty;
var currentProperty = params.missingProperty;
var uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, "" + property.replace(/^\./, ""))).title;
if (uiSchemaTitle) {
message = message.replace(currentProperty, uiSchemaTitle);
} else {
var parentSchemaTitle = get__default["default"](parentSchema, [utils.PROPERTIES_KEY, currentProperty, "title"]);
if (parentSchemaTitle) {
message = message.replace(currentProperty, parentSchemaTitle);
}
}
stack = message;
} else {
var _uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, "" + property.replace(/^\./, ""))).title;
if (_uiSchemaTitle) {
stack = ("'" + _uiSchemaTitle + "' " + message).trim();
} else {
var _parentSchemaTitle = parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.title;
if (_parentSchemaTitle) {
stack = ("'" + _parentSchemaTitle + "' " + message).trim();
}
}
}

@@ -327,3 +366,3 @@ // put data in expected format

var invalidSchemaError = rawErrors.validationError;
var errors = this.transformRJSFValidationErrors(rawErrors.errors);
var errors = this.transformRJSFValidationErrors(rawErrors.errors, uiSchema);
if (invalidSchemaError) {

@@ -330,0 +369,0 @@ errors = [].concat(errors, [{

@@ -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"),i=require("ajv8"),o=require("ajv-formats");function n(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var s=n(r),c=n(e),d=n(t),u=n(i),f=n(o);function l(){return l=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},l.apply(this,arguments)}var h={allErrors:!0,multipleOfPrecision:8,strict:!1},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*\)))$/,m=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/,p=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=u.default);var n=new o(l({},h,t));return i?f.default(n,i):!1!==i&&f.default(n),n.addFormat("data-url",m),n.addFormat("color",v),n.addKeyword(a.ADDITIONAL_PROPERTY_FLAG),n.addKeyword(a.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&n.addMetaSchema(r),c.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=s.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){return o!==a.ERRORS_KEY&&(i=i.concat(t.toErrorList(r[o],[].concat(e,[o])))),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 l({},r,((i={})[a]=e.createErrorHandler(t),i))}),t);if(c.default(r)){var a=r;return Object.keys(a).reduce((function(r,t){var i;return l({},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,i){var o,n;return"addError"===i?t:l({},t,i===a.ERRORS_KEY?((n={})[i]=r[i],n):((o={})[i]=e.unwrapErrorHandler(r[i]),o))}),{})},e.transformRJSFValidationErrors=function(r){return void 0===r&&(r=[]),r.map((function(r){var e=r.keyword,t=r.message,a=r.params,i=r.schemaPath,o=r.instancePath.replace(/\//g,"."),n=(o+" "+t).trim();return"missingProperty"in a&&(o=o?o+"."+a.missingProperty:a.missingProperty,n=t),{name:e,property:o,message:t,params:a,stack:n,schemaPath:i}}))},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);s&&(c=[].concat(c,[{stack:s.message}])),"function"==typeof i&&(c=i(c,o));var d=this.toErrorSchema(c);if(s&&(d=l({},d,{$schema:{__errors:[s.message]}})),"function"!=typeof t)return{errors:c,errorSchema:d};var u=a.getDefaultFormState(this,e,r,e,!0),f=t(u,this.createErrorHandler(u),o),h=this.unwrapErrorHandler(f);return a.mergeValidationData(this,{errors:c,errorSchema:d},h)},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)):c.default(r)?this.withIdRefPrefixObject(d.default(r)):r},r}();function y(r,e){return void 0===r&&(r={}),new p(r,e)}var E=y();exports.customizeValidator=y,exports.default=E;
"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"),i=require("lodash/get"),o=require("ajv"),n=require("ajv-formats");function s(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var c=s(r),u=s(e),d=s(t),l=s(i),f=s(o),h=s(n);function v(){return v=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},v.apply(this,arguments)}var m={allErrors:!0,multipleOfPrecision:8,strict:!1,verbose:!0},p=/^(#?([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*\)))$/,y=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/,E=["instancePath","keyword","params","schemaPath","parentSchema"],g=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=f.default);var n=new o(v({},m,t));return i?h.default(n,i):!1!==i&&h.default(n),n.addFormat("data-url",y),n.addFormat("color",p),n.addKeyword(a.ADDITIONAL_PROPERTY_FLAG),n.addKeyword(a.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&n.addMetaSchema(r),u.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=c.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){return o!==a.ERRORS_KEY&&(i=i.concat(t.toErrorList(r[o],[].concat(e,[o])))),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 v({},r,((i={})[a]=e.createErrorHandler(t),i))}),t);if(u.default(r)){var a=r;return Object.keys(a).reduce((function(r,t){var i;return v({},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,i){var o,n;return"addError"===i?t:v({},t,i===a.ERRORS_KEY?((n={})[i]=r[i],n):((o={})[i]=e.unwrapErrorHandler(r[i]),o))}),{})},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,E).message,u=void 0===c?"":c,d=t.replace(/\//g,"."),f=(d+" "+u).trim();if("missingProperty"in o){var h=o.missingProperty,v=a.getUiOptions(l.default(e,""+(d=d?d+"."+o.missingProperty:o.missingProperty).replace(/^\./,""))).title;if(v)u=u.replace(h,v);else{var m=l.default(s,[a.PROPERTIES_KEY,h,"title"]);m&&(u=u.replace(h,m))}f=u}else{var p=a.getUiOptions(l.default(e,""+d.replace(/^\./,""))).title;if(p)f=("'"+p+"' "+u).trim();else{var y=null==s?void 0:s.title;y&&(f=("'"+y+"' "+u).trim())}}return{name:i,property:d,message:u,params:o,stack:f,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=v({},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)):u.default(r)?this.withIdRefPrefixObject(d.default(r)):r},r}();function j(r,e){return void 0===r&&(r={}),new g(r,e)}var R=j();exports.customizeValidator=j,exports.default=R;
//# sourceMappingURL=validator-ajv8.cjs.production.min.js.map
import toPath from 'lodash-es/toPath';
import isObject from 'lodash-es/isObject';
import clone from 'lodash-es/clone';
import { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG, ErrorSchemaBuilder, ERRORS_KEY, getDefaultFormState, mergeValidationData, REF_KEY } from '@rjsf/utils';
import Ajv from 'ajv8';
import { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG, ErrorSchemaBuilder, ERRORS_KEY, getUiOptions, PROPERTIES_KEY, getDefaultFormState, mergeValidationData, REF_KEY } from '@rjsf/utils';
import get from 'lodash-es/get';
import Ajv from 'ajv';
import addFormats from 'ajv-formats';

@@ -22,2 +23,14 @@

}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}

@@ -27,3 +40,4 @@ var AJV_CONFIG = {

multipleOfPrecision: 8,
strict: false
strict: false,
verbose: true
};

@@ -79,2 +93,3 @@ var COLOR_FORMAT_REGEX = /^(#?([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*\)))$/;

var _excluded = ["instancePath", "keyword", "params", "schemaPath", "parentSchema"];
var ROOT_SCHEMA_PREFIX = "__rjsf_rootSchema";

@@ -233,5 +248,5 @@ /** `ValidatorType` implementation that uses the AJV 8 validation mechanism.

* @param errors - The list of AJV errors to convert to `RJSFValidationErrors`
* @private
* @protected
*/;
_proto.transformRJSFValidationErrors = function transformRJSFValidationErrors(errors) {
_proto.transformRJSFValidationErrors = function transformRJSFValidationErrors(errors, uiSchema) {
if (errors === void 0) {

@@ -243,5 +258,8 @@ errors = [];

keyword = e.keyword,
message = e.message,
params = e.params,
schemaPath = e.schemaPath;
schemaPath = e.schemaPath,
parentSchema = e.parentSchema,
rest = _objectWithoutPropertiesLoose(e, _excluded);
var _rest$message = rest.message,
message = _rest$message === void 0 ? "" : _rest$message;
var property = instancePath.replace(/\//g, ".");

@@ -251,3 +269,23 @@ var stack = (property + " " + message).trim();

property = property ? property + "." + params.missingProperty : params.missingProperty;
var currentProperty = params.missingProperty;
var uiSchemaTitle = getUiOptions(get(uiSchema, "" + property.replace(/^\./, ""))).title;
if (uiSchemaTitle) {
message = message.replace(currentProperty, uiSchemaTitle);
} else {
var parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, "title"]);
if (parentSchemaTitle) {
message = message.replace(currentProperty, parentSchemaTitle);
}
}
stack = message;
} else {
var _uiSchemaTitle = getUiOptions(get(uiSchema, "" + property.replace(/^\./, ""))).title;
if (_uiSchemaTitle) {
stack = ("'" + _uiSchemaTitle + "' " + message).trim();
} else {
var _parentSchemaTitle = parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.title;
if (_parentSchemaTitle) {
stack = ("'" + _parentSchemaTitle + "' " + message).trim();
}
}
}

@@ -313,3 +351,3 @@ // put data in expected format

var invalidSchemaError = rawErrors.validationError;
var errors = this.transformRJSFValidationErrors(rawErrors.errors);
var errors = this.transformRJSFValidationErrors(rawErrors.errors, uiSchema);
if (invalidSchemaError) {

@@ -316,0 +354,0 @@ errors = [].concat(errors, [{

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash-es/toPath'), require('lodash-es/isObject'), require('lodash-es/clone'), require('@rjsf/utils'), require('ajv8'), require('ajv-formats')) :
typeof define === 'function' && define.amd ? define(['exports', 'lodash-es/toPath', 'lodash-es/isObject', 'lodash-es/clone', '@rjsf/utils', 'ajv8', 'ajv-formats'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/validator-ajv8"] = {}, global.toPath, global.isObject, global.clone, global.utils, global.Ajv, global.addFormats));
})(this, (function (exports, toPath, isObject, clone, utils, Ajv, addFormats) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash-es/toPath'), require('lodash-es/isObject'), require('lodash-es/clone'), require('@rjsf/utils'), require('lodash-es/get'), require('ajv'), require('ajv-formats')) :
typeof define === 'function' && define.amd ? define(['exports', 'lodash-es/toPath', 'lodash-es/isObject', 'lodash-es/clone', '@rjsf/utils', 'lodash-es/get', 'ajv', 'ajv-formats'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/validator-ajv8"] = {}, global.toPath, global.isObject, global.clone, global.utils, global.get, global.Ajv, global.addFormats));
})(this, (function (exports, toPath, isObject, clone, utils, get, Ajv, addFormats) { 'use strict';

@@ -12,2 +12,3 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);

@@ -30,2 +31,14 @@ var addFormats__default = /*#__PURE__*/_interopDefaultLegacy(addFormats);

}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}

@@ -35,3 +48,4 @@ var AJV_CONFIG = {

multipleOfPrecision: 8,
strict: false
strict: false,
verbose: true
};

@@ -87,2 +101,3 @@ var COLOR_FORMAT_REGEX = /^(#?([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*\)))$/;

var _excluded = ["instancePath", "keyword", "params", "schemaPath", "parentSchema"];
var ROOT_SCHEMA_PREFIX = "__rjsf_rootSchema";

@@ -241,5 +256,5 @@ /** `ValidatorType` implementation that uses the AJV 8 validation mechanism.

* @param errors - The list of AJV errors to convert to `RJSFValidationErrors`
* @private
* @protected
*/;
_proto.transformRJSFValidationErrors = function transformRJSFValidationErrors(errors) {
_proto.transformRJSFValidationErrors = function transformRJSFValidationErrors(errors, uiSchema) {
if (errors === void 0) {

@@ -251,5 +266,8 @@ errors = [];

keyword = e.keyword,
message = e.message,
params = e.params,
schemaPath = e.schemaPath;
schemaPath = e.schemaPath,
parentSchema = e.parentSchema,
rest = _objectWithoutPropertiesLoose(e, _excluded);
var _rest$message = rest.message,
message = _rest$message === void 0 ? "" : _rest$message;
var property = instancePath.replace(/\//g, ".");

@@ -259,3 +277,23 @@ var stack = (property + " " + message).trim();

property = property ? property + "." + params.missingProperty : params.missingProperty;
var currentProperty = params.missingProperty;
var uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, "" + property.replace(/^\./, ""))).title;
if (uiSchemaTitle) {
message = message.replace(currentProperty, uiSchemaTitle);
} else {
var parentSchemaTitle = get__default["default"](parentSchema, [utils.PROPERTIES_KEY, currentProperty, "title"]);
if (parentSchemaTitle) {
message = message.replace(currentProperty, parentSchemaTitle);
}
}
stack = message;
} else {
var _uiSchemaTitle = utils.getUiOptions(get__default["default"](uiSchema, "" + property.replace(/^\./, ""))).title;
if (_uiSchemaTitle) {
stack = ("'" + _uiSchemaTitle + "' " + message).trim();
} else {
var _parentSchemaTitle = parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.title;
if (_parentSchemaTitle) {
stack = ("'" + _parentSchemaTitle + "' " + message).trim();
}
}
}

@@ -321,3 +359,3 @@ // put data in expected format

var invalidSchemaError = rawErrors.validationError;
var errors = this.transformRJSFValidationErrors(rawErrors.errors);
var errors = this.transformRJSFValidationErrors(rawErrors.errors, uiSchema);
if (invalidSchemaError) {

@@ -324,0 +362,0 @@ errors = [].concat(errors, [{

@@ -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,i,o,n){"use strict";function s(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var c=s(e),d=s(t),u=s(a),f=s(o),l=s(n);function h(){return h=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},h.apply(this,arguments)}var v={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*\)))$/,p=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/,y="__rjsf_rootSchema",j=function(){function r(r,e){this.ajv=void 0,this.localizer=void 0,this.ajv=function(r,e,t,a,o){void 0===t&&(t={}),void 0===o&&(o=f.default);var n=new o(h({},v,t));return a?l.default(n,a):!1!==a&&l.default(n),n.addFormat("data-url",p),n.addFormat("color",m),n.addKeyword(i.ADDITIONAL_PROPERTY_FLAG),n.addKeyword(i.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&n.addMetaSchema(r),d.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 i.ErrorSchemaBuilder;return r.length&&r.forEach((function(r){var t=r.message,a=c.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 a=[];return i.ERRORS_KEY in r&&(a=a.concat(r[i.ERRORS_KEY].map((function(r){var t="."+e.join(".");return{property:t,message:r,stack:t+" "+r}})))),Object.keys(r).reduce((function(a,o){return o!==i.ERRORS_KEY&&(a=a.concat(t.toErrorList(r[o],[].concat(e,[o])))),a}),a)},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 h({},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 h({},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){var o,n;return"addError"===a?t:h({},t,a===i.ERRORS_KEY?((n={})[a]=r[a],n):((o={})[a]=e.unwrapErrorHandler(r[a]),o))}),{})},e.transformRJSFValidationErrors=function(r){return void 0===r&&(r=[]),r.map((function(r){var e=r.keyword,t=r.message,a=r.params,i=r.schemaPath,o=r.instancePath.replace(/\//g,"."),n=(o+" "+t).trim();return"missingProperty"in a&&(o=o?o+"."+a.missingProperty:a.missingProperty,n=t),{name:e,property:o,message:t,params:a,stack:n,schemaPath:i}}))},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,a,o){var n=this.rawValidation(e,r),s=n.validationError,c=this.transformRJSFValidationErrors(n.errors);s&&(c=[].concat(c,[{stack:s.message}])),"function"==typeof a&&(c=a(c,o));var d=this.toErrorSchema(c);if(s&&(d=h({},d,{$schema:{__errors:[s.message]}})),"function"!=typeof t)return{errors:c,errorSchema:d};var u=i.getDefaultFormState(this,e,r,e,!0),f=t(u,this.createErrorHandler(u),o),l=this.unwrapErrorHandler(f);return i.mergeValidationData(this,{errors:c,errorSchema:d},l)},e.withIdRefPrefixObject=function(r){for(var e in r){var t=r[e];r[e]=e===i.REF_KEY&&"string"==typeof t&&t.startsWith("#")?y+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:y;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(u.default(r)):r},r}();function E(r,e){return void 0===r&&(r={}),new j(r,e)}var b=E();r.customizeValidator=E,r.default=b,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("lodash-es/get"),require("ajv"),require("ajv-formats")):"function"==typeof define&&define.amd?define(["exports","lodash-es/toPath","lodash-es/isObject","lodash-es/clone","@rjsf/utils","lodash-es/get","ajv","ajv-formats"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self)["@rjsf/validator-ajv8"]={},r.toPath,r.isObject,r.clone,r.utils,r.get,r.Ajv,r.addFormats)}(this,(function(r,e,t,a,i,o,n,s){"use strict";function c(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var d=c(e),u=c(t),l=c(a),f=c(o),h=c(n),v=c(s);function m(){return m=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},m.apply(this,arguments)}var p={allErrors:!0,multipleOfPrecision:8,strict:!1,verbose:!0},y=/^(#?([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*\)))$/,E=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/,j=["instancePath","keyword","params","schemaPath","parentSchema"],g="__rjsf_rootSchema",b=function(){function r(r,e){this.ajv=void 0,this.localizer=void 0,this.ajv=function(r,e,t,a,o){void 0===t&&(t={}),void 0===o&&(o=h.default);var n=new o(m({},p,t));return a?v.default(n,a):!1!==a&&v.default(n),n.addFormat("data-url",E),n.addFormat("color",y),n.addKeyword(i.ADDITIONAL_PROPERTY_FLAG),n.addKeyword(i.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&n.addMetaSchema(r),u.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 i.ErrorSchemaBuilder;return r.length&&r.forEach((function(r){var t=r.message,a=d.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 a=[];return i.ERRORS_KEY in r&&(a=a.concat(r[i.ERRORS_KEY].map((function(r){var t="."+e.join(".");return{property:t,message:r,stack:t+" "+r}})))),Object.keys(r).reduce((function(a,o){return o!==i.ERRORS_KEY&&(a=a.concat(t.toErrorList(r[o],[].concat(e,[o])))),a}),a)},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 m({},r,((i={})[a]=e.createErrorHandler(t),i))}),t);if(u.default(r)){var a=r;return Object.keys(a).reduce((function(r,t){var i;return m({},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){var o,n;return"addError"===a?t:m({},t,a===i.ERRORS_KEY?((n={})[a]=r[a],n):((o={})[a]=e.unwrapErrorHandler(r[a]),o))}),{})},e.transformRJSFValidationErrors=function(r,e){return void 0===r&&(r=[]),r.map((function(r){var t=r.instancePath,a=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,d=void 0===c?"":c,u=t.replace(/\//g,"."),l=(u+" "+d).trim();if("missingProperty"in o){var h=o.missingProperty,v=i.getUiOptions(f.default(e,""+(u=u?u+"."+o.missingProperty:o.missingProperty).replace(/^\./,""))).title;if(v)d=d.replace(h,v);else{var m=f.default(s,[i.PROPERTIES_KEY,h,"title"]);m&&(d=d.replace(h,m))}l=d}else{var p=i.getUiOptions(f.default(e,""+u.replace(/^\./,""))).title;if(p)l=("'"+p+"' "+d).trim();else{var y=null==s?void 0:s.title;y&&(l=("'"+y+"' "+d).trim())}}return{name:a,property:u,message:d,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,a,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 a&&(c=a(c,o));var d=this.toErrorSchema(c);if(s&&(d=m({},d,{$schema:{__errors:[s.message]}})),"function"!=typeof t)return{errors:c,errorSchema:d};var u=i.getDefaultFormState(this,e,r,e,!0),l=t(u,this.createErrorHandler(u),o),f=this.unwrapErrorHandler(l);return i.mergeValidationData(this,{errors:c,errorSchema:d},f)},e.withIdRefPrefixObject=function(r){for(var e in r){var t=r[e];r[e]=e===i.REF_KEY&&"string"==typeof t&&t.startsWith("#")?g+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:g;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)):u.default(r)?this.withIdRefPrefixObject(l.default(r)):r},r}();function O(r,e){return void 0===r&&(r={}),new b(r,e)}var R=O();r.customizeValidator=O,r.default=R,Object.defineProperty(r,"__esModule",{value:!0})}));
//# sourceMappingURL=validator-ajv8.umd.production.min.js.map
{
"name": "@rjsf/validator-ajv8",
"version": "5.0.0-beta.16",
"version": "5.0.0-beta.17",
"main": "dist/index.js",

@@ -30,4 +30,4 @@ "module": "dist/validator-ajv8.esm.js",

"dependencies": {
"ajv": "^8.11.0",
"ajv-formats": "^2.1.1",
"ajv8": "npm:ajv@^8.11.0",
"lodash": "^4.17.15",

@@ -37,19 +37,19 @@ "lodash-es": "^4.17.15"

"peerDependencies": {
"@rjsf/utils": "^5.0.0-beta.12"
"@rjsf/utils": "^5.0.0-beta.16"
},
"devDependencies": {
"@babel/core": "^7.19.6",
"@babel/core": "^7.20.12",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-transform-modules-commonjs": "^7.19.6",
"@babel/plugin-transform-react-jsx": "^7.19.0",
"@babel/preset-env": "^7.19.4",
"@babel/plugin-transform-react-jsx": "^7.20.7",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@rjsf/utils": "^5.0.0-beta.16",
"@rjsf/utils": "^5.0.0-beta.17",
"@types/jest-expect-message": "^1.1.0",
"@types/json-schema": "^7.0.9",
"@types/lodash": "^4.14.186",
"dts-cli": "^1.6.0",
"eslint": "^8.26.0",
"@types/lodash": "^4.14.191",
"dts-cli": "^1.6.3",
"eslint": "^8.31.0",
"jest-expect-message": "^1.1.3",
"rimraf": "^3.0.2"
"rimraf": "^4.0.4"
},

@@ -77,3 +77,3 @@ "publishConfig": {

"license": "Apache-2.0",
"gitHead": "13bf3cf29c7afad3baed22b1463278c1f4ae1a94"
"gitHead": "b0163ffdb06df1dea51cda3141bf4ca1889f8e49"
}

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