Code

ReferenceSchema API

s.code()

Source code or configuration, edited in a code editor with syntax highlighting.

Use it for

  • Code samples on docs and blog pages
  • Embed snippets and configuration

Reference

s.code(options?)

schema

A string edited in a code editor. Unlike s.string() it is never stega encoded, so the code reaches your app exactly as it was written.

In Val Studio

Options

languagestring

The language to highlight. Leave it out for a plain monospaced editor.

s.code({ language: "typescript" })

Example

A code sample on a docs page

TypeScript
const schema = s.object({
  snippet: s.code({ language: "typescript" }),
});
See alsostring