Form Validation Schema
Last updated
Was this helpful?
Last updated
Was this helpful?
Schemas are structured definitions that describe the format, rules, and relationships of data within a system. They ensure consistency and validate inputs. The Form Schema defines the structure and properties of form elements, including fields, layouts, and attributes. This documentation breaks down the schema’s properties, usage examples, and key considerations for implementation.
This section summarizes the purpose and key characteristics of the Form Schema.
Schema Name: Form Schema
Purpose: Defines the structure of forms, including fields, layouts, and form-level attributes.
Mandatory Fields: fields
Related Schemas:
Used alongside field-specific schemas to define input types and their properties.
Reference the for the full list of properties.
The following table lists the field descriptions along with their corresponding data type, whether or not they are mandatory, and their description.
title
string
No
The title of the form.
description
string
No
A description of the form.
fields
object
Yes
Defines the form fields and their properties.
layout
array
No
Specifies the arrangement of fields in the form.
attributes
object
No
Form-level attributes (e.g., action
, method
, enctype
).
fields
Property
Type: Object with dynamic keys matching the pattern ^[a-zA-Z0-9_-]+$
.
Each field must include:
type
(string, required): The input type (e.g., text
, email
, checkbox
).
label
(string, optional): The display label for the field.
canBeRemovedFromLayout
(boolean, optional): Whether the field can be removed from the layout.
removeFromLayout
(boolean, optional): Whether the field is excluded from the layout.
attributes
(object, optional): Field-specific HTML attributes.
options
(object/array, optional): Used for fields like select
, radio
, etc.
layout
Property
Type: Array of arrays or objects.
Defines the visual arrangement of fields.
Can include:
Simple arrays of field names (e.g., ["field1", "field2"]
).
Objects with legend
(string) and fields
(array of arrays) for grouped sections.
attributes
Property
Type: Object.
Defines form-level HTML attributes.
Required: action
(string).
Other optional properties include method
, enctype
, target
, etc.
This section demonstrates a comprehensive auto loan pre-approval form definition that showcases the full capabilities of the form specification. The example includes various field types, layout configurations, and form attributes to illustrate a real-world implementation.
The following example represents a complete auto loan application form, featuring:
Multiple field types (text, select, radio, number, submit)
Required field validation
Conditional layout controls
Comprehensive form attributes
Demonstration of all supported HTML input types (even those hidden from the main layout)
Structure Object Breakdown
The structure
object contains all form configuration elements:
Metadata:
title
: Form header displayed to users
description
: Explanatory text about the form's purpose
Fields Configuration:
Each field has type-specific properties and attributes
Includes layout control flags (canBeRemovedFromLayout
, removeFromLayout
)
Supports all HTML input types (demonstrated in hidden fields)
Required field validation through attributes
Layout Management:
The layout
array defines the visual organization of fields
Supports multi-column layouts through nested arrays
Hidden fields are included in definition but removed from display
Form Attributes:
Comprehensive HTML form attributes
Supports modern features like charset declaration and autocomplete
Configurable submission handling (method, enctype, target)
Consider the following when using the Form Schema:
Dynamic Fields: Use patternProperties
to validate field names.
Extensibility: Custom attributes can be added under data-*
patterns.
Layout Flexibility: Use arrays or objects in layout
for simple or grouped arrangements.