Defining Schemas
Luthor has a concept of “schemas” which are used to define the structure of the data that you want to validate. Essentially, a schema is a Map
that defines the structure of the data that you want to validate. The keys of the Map
are the names of the fields that you want to validate, and the values are the rules that you want to apply to those fields.
Here’s an example of a simple schema:
Above, we define a schema for a person
object that has two fields: name
and age
. The name
field is a required string that must have a minimum length of 1, and the age
field is a required integer.
You can also define nested schemas: