Types helpers

Type helpers

Inferring schema

import { s, t } from "@/val.config"

const schema = s.object({ example: s.string() })
const SchemaType = t.inferSchema<typeof schema>

Decoding Val

If you need to know the raw type of a Val value, you can use DecodeVal. This is useful if you want to input values, as they are, not as ValEncodedStrings.

const SchemaTypeExample = {
  astring: ValEncodedString
} // this type would typically be obtained using t.inferSchema
const DecodedSchema = DecodeVal<SchemaTypeExample>
// type equals: { astring: string }

Types

ValEncodedString

ValEncodedString is a string that has hidden data (using steganography). It is used in Val to tag html elements with the Val path, which is used by the overlay so users can click a string and edit directly in the app.

Schema

Schema defines a Val Schema. Its type parameter always represents the raw type. E.g. `s.string()` is a Schema<string>.