New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@rjsf/core

Package Overview
Dependencies
Maintainers
2
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rjsf/core - npm Package Compare versions

Comparing version

to
5.24.4

5

lib/components/Form.d.ts

@@ -287,2 +287,7 @@ import { Component, ElementType, FormEvent, ReactNode, Ref, RefObject } from 'react';

shouldComponentUpdate(nextProps: FormProps<T, S, F>, nextState: FormState<T, S, F>): boolean;
/** Gets the previously raised customValidate errors.
*
* @returns the previous customValidate errors
*/
private getPreviousCustomValidateErrors;
/** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the

@@ -289,0 +294,0 @@ * `schemaUtils` in the state), returning the results.

42

lib/components/Form.js
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Component, createRef } from 'react';
import { createSchemaUtils, deepEquals, getChangedFields, getTemplate, getUiOptions, isObject, mergeObjects, NAME_KEY, RJSF_ADDITIONAL_PROPERTIES_FLAG, shouldRender, SUBMIT_BTN_OPTIONS_KEY, toErrorList, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, validationDataMerge, } from '@rjsf/utils';
import { createSchemaUtils, deepEquals, getChangedFields, getTemplate, getUiOptions, isObject, mergeObjects, NAME_KEY, RJSF_ADDITIONAL_PROPERTIES_FLAG, shouldRender, SUBMIT_BTN_OPTIONS_KEY, toErrorList, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, validationDataMerge, createErrorHandler, unwrapErrorHandler, } from '@rjsf/utils';
import _forEach from 'lodash/forEach';

@@ -474,2 +474,17 @@ import _get from 'lodash/get';

}
/** Gets the previously raised customValidate errors.
*
* @returns the previous customValidate errors
*/
getPreviousCustomValidateErrors() {
const { customValidate, uiSchema } = this.props;
const prevFormData = this.state.formData;
let customValidateErrors = {};
if (typeof customValidate === 'function') {
const errorHandler = customValidate(prevFormData, createErrorHandler(prevFormData), uiSchema);
const userErrorSchema = unwrapErrorHandler(errorHandler);
customValidateErrors = userErrorSchema;
}
return customValidateErrors;
}
/** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the

@@ -512,10 +527,27 @@ * `schemaUtils` in the state), returning the results.

}
const prevCustomValidateErrors = this.getPreviousCustomValidateErrors();
// Filtering out the previous raised customValidate errors so that they are cleared when no longer valid.
const filterPreviousCustomErrors = (errors = [], prevCustomErrors) => {
if (errors.length === 0) {
return errors;
}
return errors.filter((error) => {
return !prevCustomErrors.includes(error);
});
};
// Removing undefined, null and empty errors.
const filterNilOrEmptyErrors = (errors) => {
const filterNilOrEmptyErrors = (errors, previousCustomValidateErrors = {}) => {
_forEach(errors, (errorAtKey, errorKey) => {
if (_isNil(errorAtKey)) {
const prevCustomValidateErrorAtKey = previousCustomValidateErrors[errorKey];
if (_isNil(errorAtKey) || (Array.isArray(errorAtKey) && errorAtKey.length === 0)) {
delete errors[errorKey];
}
else if (isObject(errorAtKey) &&
isObject(prevCustomValidateErrorAtKey) &&
Array.isArray(prevCustomValidateErrorAtKey === null || prevCustomValidateErrorAtKey === void 0 ? void 0 : prevCustomValidateErrorAtKey.__errors)) {
// if previous customValidate error is an object and has __errors array, filter out the errors previous customValidate errors.
errors[errorKey] = filterPreviousCustomErrors(errorAtKey.__errors, prevCustomValidateErrorAtKey.__errors);
}
else if (typeof errorAtKey === 'object' && !Array.isArray(errorAtKey.__errors)) {
filterNilOrEmptyErrors(errorAtKey);
filterNilOrEmptyErrors(errorAtKey, previousCustomValidateErrors[errorKey]);
}

@@ -525,3 +557,3 @@ });

};
return filterNilOrEmptyErrors(filteredErrors);
return filterNilOrEmptyErrors(filteredErrors, prevCustomValidateErrors);
}

@@ -528,0 +560,0 @@ /**

20

package.json
{
"name": "@rjsf/core",
"version": "5.24.3",
"version": "5.24.4",
"description": "A simple React component capable of building HTML forms out of a JSON schema.",
"scripts": {
"build:ts": "tsc -b",
"compileReplacer": "tsc -p tsconfig.replacer.json",
"build:ts": "npm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",

@@ -30,2 +31,7 @@ "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/index.esm.js --sourcemap --packages=external --format=esm",

"typings": "lib/index.d.ts",
"exports": {
"require": "./dist/index.js",
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
},
"files": [

@@ -58,6 +64,6 @@ "dist",

"@babel/preset-typescript": "^7.23.3",
"@rjsf/snapshot-tests": "^5.24.3",
"@rjsf/utils": "^5.24.3",
"@rjsf/validator-ajv6": "^5.24.3",
"@rjsf/validator-ajv8": "^5.24.3",
"@rjsf/snapshot-tests": "^5.24.4",
"@rjsf/utils": "^5.24.4",
"@rjsf/validator-ajv6": "^5.24.4",
"@rjsf/validator-ajv8": "^5.24.4",
"@types/jest": "^29.5.12",

@@ -108,3 +114,3 @@ "@types/lodash": "^4.14.202",

},
"gitHead": "76eff41ea01c073dd20ec5712fd21fb99eb11787"
"gitHead": "fadbd45a4a565a773ba6e31f6f26f1b5b55c1377"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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