Builds schema which defines shape of the form values and type of validation errors.
The schema is used not only for compile-time type-safety but also for runtime validation of form values.
The schema can be defined top-level, so that it can be exported to nested Form components for usage together with useField
hook.
FormSchema - used to interact with Formts API and point to specific form fields
import { FormSchemaBuilder, FormFields } from "@virtuslab/formts"
const Schema = new FormSchemaBuilder()
.fields({
name: FormFields.string(),
age: FormFields.number(),
})
.errors<string>()
.build()
Private
decodersPrivate
buildDefine form fields as dictionary of decoders. Use FormFields
import.
new FormSchemaBuilder()
.fields({
name: FormFields.string(),
age: FormFields.number(),
})
Generated using TypeDoc
Builds schema which defines shape of the form values and type of validation errors. The schema is used not only for compile-time type-safety but also for runtime validation of form values. The schema can be defined top-level, so that it can be exported to nested Form components for usage together with
useField
hook.Returns
FormSchema - used to interact with Formts API and point to specific form fields
Example