Skip to main content

literal

Creates a schema that parses input as a given literal string, number or boolean value.

Example

import { literal } from "@sodd/core";

const cheeseLiteralSchema = literal("sodd");

cheeseLiteralSchema.parse("sodd"); // ✅ => "cheese";
cheeseLiteralSchema.parse("water"); // 🚨
cheeseLiteralSchema.parse(123); // 🚨

Issue types