Action creators for dispatching state changes in JSON Forms. These functions create action objects compatible with Redux reducers.
Core Actions
init
Initialize JSON Forms with data, schema, and UI schema.
function init(
data: any,
schema?: JsonSchema,
uischema?: UISchemaElement,
options?: InitActionOptions | AJV
): InitAction
The JSON schema describing the data structure. If not provided, a schema will be generated from the data.
The UI schema describing how to render the form. If not provided, a default UI schema will be generated.
Configuration options:
ajv: Custom AJV instance for validation
validationMode: Validation mode (‘ValidateAndShow’, ‘ValidateAndHide’, ‘NoValidation’)
additionalErrors: Additional validation errors
Action object with type jsonforms/INIT
Example:
import { init } from '@jsonforms/core';
const action = init(
{ name: 'John', age: 30 },
{
type: 'object',
properties: {
name: { type: 'string' },
age: { type: 'number' }
}
},
{
type: 'VerticalLayout',
elements: [
{ type: 'Control', scope: '#/properties/name' },
{ type: 'Control', scope: '#/properties/age' }
]
}
);
update
Update form data at a specific path.
function update(
path: string,
updater: (existingData: any) => any,
context?: object
): UpdateAction
Data path in dot notation (e.g., ‘person.address.city’)
updater
(existingData: any) => any
required
Function that receives the current value and returns the new value
Optional context object, typically an UpdateArrayContext for array operations
Action object with type jsonforms/UPDATE
Example:
import { update } from '@jsonforms/core';
// Update a simple value
const action = update('name', () => 'Jane');
// Update with context for array operations
const arrayAction = update(
'items',
(items) => [...items, newItem],
{ type: 'ADD', values: [newItem] }
);
updateCore
Update multiple core state properties at once.
function updateCore(
data: any,
schema: JsonSchema,
uischema?: UISchemaElement,
options?: AJV | InitActionOptions
): UpdateCoreAction
AJV instance or options object
Action object with type jsonforms/UPDATE_CORE
setSchema
Set or update the JSON schema.
function setSchema(schema: JsonSchema): SetSchemaAction
Action object with type jsonforms/SET_SCHEMA
setUISchema
Set or update the UI schema.
function setUISchema(uischema: UISchemaElement): SetUISchemaAction
Action object with type jsonforms/SET_UISCHEMA
updateErrors
Update validation errors.
function updateErrors(errors: ErrorObject[]): UpdateErrorsAction
Array of AJV error objects
Action object with type jsonforms/UPDATE_ERRORS
setValidationMode
Set the validation mode.
function setValidationMode(
validationMode: ValidationMode
): SetValidationModeAction
One of: ‘ValidateAndShow’, ‘ValidateAndHide’, ‘NoValidation’
Action object with type jsonforms/SET_VALIDATION_MODE
Renderer Actions
registerRenderer
Register a custom renderer.
function registerRenderer(
tester: RankedTester,
renderer: any
): AddRendererAction
Function that returns a rank number indicating renderer applicability
The renderer component (React, Angular, Vue, etc.)
Action object with type jsonforms/ADD_RENDERER
unregisterRenderer
Unregister a custom renderer.
function unregisterRenderer(
tester: RankedTester,
renderer: any
): RemoveRendererAction
registerCell
Register a custom cell renderer.
function registerCell(
tester: RankedTester,
cell: any
): AddCellRendererAction
unregisterCell
Unregister a custom cell renderer.
function unregisterCell(
tester: RankedTester,
cell: any
): RemoveCellRendererAction
UI Schema Actions
registerUISchema
Register a UI schema for dynamic resolution.
function registerUISchema(
tester: UISchemaTester,
uischema: UISchemaElement
): AddUISchemaAction
Function that returns a rank number for schema matching
The UI schema to register
Action object with type jsonforms/ADD_UI_SCHEMA
unregisterUISchema
Unregister a UI schema.
function unregisterUISchema(
tester: UISchemaTester
): RemoveUISchemaAction
Configuration Actions
setConfig
Set form-wide configuration options.
function setConfig(config: any): SetConfigAction
Configuration object (structure depends on renderers)
Action object with type jsonforms/SET_CONFIG
Internationalization Actions
setLocale
Set the current locale.
function setLocale(locale: string | undefined): SetLocaleAction
setTranslator
Set translation functions.
function setTranslator(
translator?: Translator,
errorTranslator?: ErrorTranslator
): SetTranslatorAction
updateI18n
Update locale and translators.
function updateI18n(
locale: string | undefined,
translator: Translator | undefined,
errorTranslator: ErrorTranslator | undefined
): UpdateI18nAction
Default Data Actions
registerDefaultData
Register default data for a schema path.
function registerDefaultData(
schemaPath: string,
data: any
): RegisterDefaultDataAction
unregisterDefaultData
Unregister default data for a schema path.
function unregisterDefaultData(
schemaPath: string
): UnregisterDefaultDataAction
Action Type Constants
export const INIT = 'jsonforms/INIT';
export const UPDATE_CORE = 'jsonforms/UPDATE_CORE';
export const UPDATE_DATA = 'jsonforms/UPDATE';
export const UPDATE_ERRORS = 'jsonforms/UPDATE_ERRORS';
export const SET_SCHEMA = 'jsonforms/SET_SCHEMA';
export const SET_UISCHEMA = 'jsonforms/SET_UISCHEMA';
export const SET_VALIDATION_MODE = 'jsonforms/SET_VALIDATION_MODE';
export const SET_AJV = 'jsonforms/SET_AJV';
export const ADD_RENDERER = 'jsonforms/ADD_RENDERER';
export const REMOVE_RENDERER = 'jsonforms/REMOVE_RENDERER';
export const ADD_CELL = 'jsonforms/ADD_CELL';
export const REMOVE_CELL = 'jsonforms/REMOVE_CELL';
export const SET_CONFIG = 'jsonforms/SET_CONFIG';
export const ADD_UI_SCHEMA = 'jsonforms/ADD_UI_SCHEMA';
export const REMOVE_UI_SCHEMA = 'jsonforms/REMOVE_UI_SCHEMA';
export const SET_LOCALE = 'jsonforms/SET_LOCALE';
export const SET_TRANSLATOR = 'jsonforms/SET_TRANSLATOR';
export const UPDATE_I18N = 'jsonforms/UPDATE_I18N';
export const ADD_DEFAULT_DATA = 'jsonforms/ADD_DEFAULT_DATA';
export const REMOVE_DEFAULT_DATA = 'jsonforms/REMOVE_DEFAULT_DATA';