Overview

String Schema

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:
.validate: method

Custom validation function

.maxLength(n): method

Maximum length validation

.minLength(n): method

Minimum length validation

.regex(pattern): method

Regex pattern validation

s.string().regex(/Example/)
.render: method

Change how this string is rendered in Val Studio. Options include:

  • textarea - Multi-line text input

  • code - Code editor with syntax highlighting (requires language option)

s.string().render({ as: "textarea" })
s.string().render({ as: "code", language: "typescript" })
Examples:
Basic validation
s.string().maxLength(100)
Textarea render
const schema = s.object({
  description: s.string().render({ as: "textarea" }),
});
Code editor render
const schema = s.object({
  jsonConfig: s.string().render({ as: "code", language: "json" }),
  tsCode: s.string().render({ as: "code", language: "typescript" }),
  cssStyles: s.string().render({ as: "code", language: "css" }),
});