JsonFormState

interface JsonFormState

An object representing a form described by the standard Jsonforms.io.

This interface is implemented by states of form containers in order to provide a low-level form api control to edit the content in fields or to mark some of them in error mode.

Functions

Link copied to clipboard
abstract fun error(id: String): State<FieldError?>

Observe the error mode of a specific key as a compose state to be informed by any mode change. This function is used internally by JsonForm components to be updated automatically when you mark a field in error or when you call validate function and some requirements or patterns aren't respected.

Link copied to clipboard
abstract operator fun get(key: String): State<Any?>

Observe the value of a specific key as a compose state to be informed by any change. This function is used internally by JsonForm components to be updated automatically when the user type or interact with your fields.

Link copied to clipboard
abstract fun getData(): Map<String, Any?>

Get data displayed in your form in a Map. Note that if form values are edited after your call to this function, values won't be updated in your Map object. If you want to observe a specific value of a control key, see get function which return a compose State.

Link copied to clipboard
abstract fun getValue(key: String): Any?

Get a specific value of a control key. Note that if this field is updated after your call to this function, you won't be notified about this change. If you want to observe this value, see get function which return a compose State.

Link copied to clipboard
abstract fun markAsErrors(properties: List<FieldError>)

Mark a list of fields in error. Note that JsonForm component already handle error states for you according to your requirements and patterns described in your Schema. If you are using this function, you need to apply and handle these errors by your own way.

Link copied to clipboard
abstract operator fun set(key: String, value: Any)

Edit value of a field. New values are observed by fields and impact directly your form.

Link copied to clipboard
abstract suspend fun validate(schema: Schema, uiSchema: UiSchema): Boolean

Validate if requirements and patterns described in Schema are respected to submit your form.