![PyPI Slashes Malware Response Time: 90% of Issues Resolved in Under 24 Hours](https://cdn.sanity.io/images/cgdhsj6q/production/eee3e3fc69826f43dfc3366b71472d981003a5cb-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Slashes Malware Response Time: 90% of Issues Resolved in Under 24 Hours
PyPI has drastically improved its malware response times, resolving 90% of issues in under 24 hours and removing 900 projects since March 2024.
@rjsf/utils
Advanced tools
Package description
@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.
Changelog
5.4.0
ObjectFieldTemplate
to hide the titles and descriptions when displayLabel
is true (including globally), fixing #3231CheckboxWidget
to show the description
using the DescriptionFieldTemplate
, fixing #2791CheckboxesWidget
and SelectWidget
to show the label
using the TitleFieldTemplate
, fixing #2134ObjectFieldTemplate
to hide the titles and descriptions when displayLabel
is true (including globally), fixing #3231CheckboxWidget
to show the description
using the DescriptionFieldTemplate
, fixing #2791RangeWidget
to fix the label hiding bug using labelValue()
ObjectFieldTemplate
to hide the titles and descriptions when displayLabel
is true (including globally), fixing #3231CheckboxesWidget
, CheckboxWidget
, RadioWidget
and SelectWidget
to hide labels when hideLabel
is true using the new labelValue()
helper (including globally)CheckboxWidget
to show the description
using the DescriptionFieldTemplate
, fixing #2791FileWidget
to show a preview of images and a download link for non-images when the filePreview
options is set to true in the UiSchema
ArrayField
, BooleanField
, MultiSelectField
and StringField
to pass label
(read from uiSchema.title
|| schema.title
|| name
) and hideLabel
down to all of the Widgets
they render, fixing #827, #2636, #2399 and #3531ObjectField
, ObjectFieldTemplate
, ArrayFieldDescriptionTemplate
, ArrayFieldTitleTemplate
and CheckboxWidget
to hide the titles and descriptions when hideLabel
is true using the new labelValue()
helper (including globally), fixing #3231CheckboxWidget
to use the labelValue()
function for hiding labelsFieldTemplate
and ObjectFieldTemplate
to hide the titles and descriptions when displayLabel
is true (including globally), fixing #3231BaseInputTemplate
, CheckboxesWidget
, CheckboxWidget
, ColorWidget
, DateWidget
, RadioWidget
, RangeWidget
, SelectWidget
and UpDownWidget
to hide labels when hideLabel
is true using the new labelValue()
helper (including globally)
FluentLabel
component out of CheckboxesWidget
, ColorWidget
, RangeWidget
and UpDownWidget
CheckboxWidget
to show the description
using the DescriptionFieldTemplate
, fixing #2791ObjectFieldTemplate
to hide the titles and descriptions when displayLabel
is true (including globally), fixing #3231BaseInputTemplate
, CheckboxesWidget
, CheckboxWidget
, RadioWidget
, RangeWidget
and SelectWidget
to hide labels when hideLabel
is true using the new labelValue()
helper (including globally)CheckboxWidget
to show the description
using the DescriptionFieldTemplate
, fixing #2791ObjectFieldTemplate
to hide the titles and descriptions when displayLabel
is true (including globally), fixing #3231BaseInputTemplate
, CheckboxesWidget
, CheckboxWidget
, RadioWidget
, RangeWidget
and SelectWidget
to hide labels when hideLabel
is true using the new labelValue()
helper (including globally)CheckboxWidget
to show the description
using the DescriptionFieldTemplate
, fixing #2791ObjectFieldTemplate
to hide the titles and descriptions when displayLabel
is true (including globally), fixing #3231BaseInputTemplate
, CheckboxesWidget
, CheckboxWidget
, SelectWidget
and TextareaWidget
to hide labels when hideLabel
is true using the new labelValue()
helper (including globally)CheckboxWidget
to show the description
using the DescriptionFieldTemplate
, fixing #2791UiSchema
to support the optional filePreview?: boolean
option and to add a new TranslatableString.PreviewLabel
to the enums
WidgetProps
to add an optional hideLabel?: boolean
field to better support hiding labelslabelValue()
helper function to better support hiding labelstoErrorList()
and unwrapErrorHandler()
by ensuring objects before recursingAntD Customization
documentation with references to it in the form-props
and uiSchema
documentationuiSchema
documentation to add the filePreview
optionwidgets
documentation to add the new, optional hideLabel
proputility-functions
documentation to add the new labelValue()
functionReadme
Utility functions for react-jsonschema-form
.
Explore the docs »
View Playground
·
Report Bug
·
Request Feature
Exports utils
functions for react-jsonschema-form
.
yarn add @rjsf/utils
import * as Utils from '@rjsf/utils';
Utility function documentation
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
FAQs
Utility functions for @rjsf/core
The npm package @rjsf/utils receives a total of 184,809 weekly downloads. As such, @rjsf/utils popularity was classified as popular.
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
PyPI has drastically improved its malware response times, resolving 90% of issues in under 24 hours and removing 900 projects since March 2024.
Security News
Research
The Socket Research team breaks down an obfuscated script designed to facilitate unauthorized file uploads to multiple external services.
Security News
Node.js has automated its security release process, doubling the number of releases, and is re-evaluating unsupported experimental features with the Next 10 group to enhance security.