Table of Contents
Schema Types
s.string()
Use the s.string() schema to represent text. You can use the `render` method to change how strings are represented in the UI.
Methods:
Custom validation function
Maximum length validation
Minimum length validation
Regex pattern validation
Change how this string is rendered in the UI. When it is configured to be rendered as textarea, a textarea is used instead of a regular input field.
Example:
Example
s.number()
Number type with optional validation
Methods:
Custom validation function
Minimum value validation
Maximum value validation
Example:
Example
s.boolean()
Boolean type
Methods:
Custom validation function
Example:
Example
s.literal(string)
Literal value type. This is mainly used together with unions. It is rendered as a dropdown menu in the UI
Methods:
Custom validation function
Example:
Example
s.object(object)
Object type with defined properties
Methods:
Custom validation function
Example:
Example
s.array(schema)
Array type with element schema
Methods:
Custom validation function
Example:
Example
s.record(schema)
Record type with element schema
A record is a collection of key-value pairs. It can be used as a list of objects that have a unique key.
Methods:
Custom validation function
Render the record as a list
Use the router method to automatically generate pages for each entry in the record
Example:
s.union(...s.literal(value))
Union type (one of multiple literal values). Rendered as a dropdown menu in the UI
Methods:
Custom validation function
Example:
Example
s.union("type", ...s.literal(value))
Discriminated (tagged) union type. Rendered as an objectct where the first field is the tag type which is rendered as a dropdown in the UI.
Methods:
Custom validation function
Example:
Example
s.keyOf(schema)
Key reference to another Val module
Methods:
Custom validation function
Example:
Example
s.image()
Images. Use s.image for schema, then c.image for content. Also note by adding .remote you can enable remote images
Options:
The accept value is a comma-separated list of one or more image types, or unique file type specifiers, describing which file types to allow.
Methods:
Custom validation function
Enable remote images
Example:
Example
s.file()
Generic files. Use s.file for schema, then c.file for content.
NOTE: if you limit the accept to video as the example below, the file will be treated as a video in Val Studio.
Options:
The accept value is a comma-separated list of one or more image types, or unique file type specifiers, describing which file types to allow.
Methods:
Custom validation function
Enable remote files
Example:
s.richtext(options)
Rich text with configurable formatting options
Methods:
Custom validation function
Example:
Example
.nullable()
Makes any schema type nullable
Example:
Example
.validate()
Custom validation function