Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@rjsf/utils
Advanced tools
@rjsf/utils is a utility library for React JSON Schema Form (RJSF). It provides a set of helper functions and utilities to work with JSON schemas, form data, and UI schemas. This package is designed to simplify the process of creating and managing forms using JSON schema definitions.
Schema Validation
This feature allows you to validate form data against a JSON schema. The `validateFormData` function takes form data and a schema as inputs and returns validation errors if any.
const { validateFormData } = require('@rjsf/utils');
const schema = { type: 'object', properties: { name: { type: 'string' } } };
const formData = { name: 'John Doe' };
const result = validateFormData(formData, schema);
console.log(result.errors);
Schema Merging
This feature allows you to merge multiple JSON schemas into one. The `mergeSchemas` function takes two or more schemas and combines them into a single schema.
const { mergeSchemas } = require('@rjsf/utils');
const schema1 = { type: 'object', properties: { name: { type: 'string' } } };
const schema2 = { type: 'object', properties: { age: { type: 'number' } } };
const mergedSchema = mergeSchemas(schema1, schema2);
console.log(mergedSchema);
Form Data Manipulation
This feature allows you to manipulate form data based on a schema. The `getDefaultFormState` function takes a schema and form data as inputs and returns the default form state.
const { getDefaultFormState } = require('@rjsf/utils');
const schema = { type: 'object', properties: { name: { type: 'string' }, age: { type: 'number' } } };
const formData = { name: 'John Doe' };
const defaultFormData = getDefaultFormState(schema, formData);
console.log(defaultFormData);
AJV (Another JSON Schema Validator) is a popular JSON schema validator. It provides high-performance validation of JSON schemas and is widely used in the JavaScript ecosystem. Compared to @rjsf/utils, AJV focuses more on schema validation and less on form-specific utilities.
JSON Schema Faker is a library that generates fake data based on a JSON schema. It is useful for testing and prototyping. While @rjsf/utils focuses on form utilities, JSON Schema Faker is more about generating mock data from schemas.
React JSONSchema Form is a library for building forms from JSON schema definitions. It includes a set of utilities similar to @rjsf/utils but is more focused on the form rendering aspect. @rjsf/utils can be seen as a subset of the utilities provided by React JSONSchema Form.
AJV-6 based validator plugin for react-jsonschema-form
.
Explore the docs »
View Playground
·
Report Bug
·
Request Feature
Exports utils
plugin for react-jsonschema-form
.
yarn add @rjsf/utils
import * as Utils from '@rjsf/utils';
See the open issues for a list of proposed features (and known issues).
Read our contributors' guide to get started.
rjsf team: https://github.com/orgs/rjsf-team/people
GitHub repository: https://github.com/rjsf-team/react-jsonschema-form
v5.0.0-beta.1
@rjsf/utils
library functions and typestemplates
as part of the fix for https://github.com/rjsf-team/react-jsonschema-form/issues/2526
BaseInputTemplate
should fix (https://github.com/rjsf-team/react-jsonschema-form/issues/2926, https://github.com/rjsf-team/react-jsonschema-form/issues/2889, https://github.com/rjsf-team/react-jsonschema-form/issues/2875, https://github.com/rjsf-team/react-jsonschema-form/issues/2223)title
and description
consistent across themes, fixing (https://github.com/rjsf-team/react-jsonschema-form/issues/2481, https://github.com/rjsf-team/react-jsonschema-form/issues/2363, https://github.com/rjsf-team/react-jsonschema-form/issues/2219)package.json
and package-lock.json
files to be built and maintained by Node 16.utils.js
file from core
into independent functions.
types
from core
in utils
to better match the implementation across all themes
formData
change when liveOmit=true
when "additionalProperties: false" issue 1507 (https://github.com/rjsf-team/react-jsonschema-form/pull/2631)validator.js
file from core
into independent functions as well as a class that implements the new ValidatorType
interface.
ajv
instance.toErrorList()
was made so that it takes fieldPath: string[]
rather than fieldName='root'
as part of the fix to (https://github.com/rjsf-team/react-jsonschema-form/issues/1596)
errors
also now adds property
from the fieldPath
along with the proper path from the property
to the stack
message, making it consistent with the AJV errors.
stack
attribute would say root: error message
; now it says . error message
errors
when merged with custom validation, fixing (https://github.com/rjsf-team/react-jsonschema-form/issues/1596).ui:emptyValue
now works with selects (https://github.com/rjsf-team/react-jsonschema-form/issues/1041)utils.js
into the new @rjsf/utils
fixes (https://github.com/rjsf-team/react-jsonschema-form/issues/2719)ui:field
with anyOf or oneOf no longer rendered twice (#2890)anyOf
and oneOf
getting incorrect, potentially duplicate ids when combined with array (https://github.com/rjsf-team/react-jsonschema-form/issues/2197)formContext
is now passed properly to SchemaField
, fixes (https://github.com/rjsf-team/react-jsonschema-form/issues/2394, https://github.com/rjsf-team/react-jsonschema-form/issues/2274)ui:duplicateKeySuffixSeparator
to customize how duplicate object keys are renamed when using additionalProperties
.extraErrors
are now consistently appended onto the end of the schema validation-based errors
information that is returned via the onErrors()
callback when submit fails.
errors
during the merge process, fixing (https://github.com/rjsf-team/react-jsonschema-form/issues/1596).RadioWidget
to no longer use random numbers fixing (https://github.com/rjsf-team/react-jsonschema-form/issues/2461)onChange
handler in the new set of props if it changed, fixing (https://github.com/rjsf-team/react-jsonschema-form/issues/1708).onChange
when formData
is controlled prop, fixing (https://github.com/rjsf-team/react-jsonschema-form/issues/513),@rollup/plugin-replace
to replace antd/lib
and rc-picker/lib
with antd/es
and rc-picker/es
respectively, fixing (https://github.com/rjsf-team/react-jsonschema-form/issues/2962)withTheme
customizations should work properly now (https://github.com/rjsf-team/react-jsonschema-form/issues/2058)ArrayFieldTemplate
refactor seems to have fixed https://github.com/rjsf-team/react-jsonschema-form/issues/2775SelectField
(https://github.com/rjsf-team/react-jsonschema-form/issues/2616, https://github.com/rjsf-team/react-jsonschema-form/issues/2875)@rjsf/mui
) was split out of the theme for version 4 (i.e. @rjsf/material-ui
) to resolve the following issues:
inputType
in uiSchema (https://github.com/rjsf-team/react-jsonschema-form/issues/2057)
step
for number
type (https://github.com/rjsf-team/react-jsonschema-form/issues/2488)@rjsf/mui
) was split out of the theme for version 4 (i.e. @rjsf/material-ui
) to resolve the following issues:
inputType
in uiSchema (https://github.com/rjsf-team/react-jsonschema-form/issues/2057)
step
for number
type (https://github.com/rjsf-team/react-jsonschema-form/issues/2488)main
definition in semantic-ui
to fix (https://github.com/withastro/astro/issues/4357)ui:field
with anyOf
(#2890)FAQs
Utility functions for @rjsf/core
We found that @rjsf/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.