@lucid-softworks/schema-core
v0.1.0
Published
Composable synchronous schema parsing contracts and structured errors.
Downloads
258
Maintainers
Readme
@lucid-softworks/schema-core
The small contract shared by the Lucid schema ecosystem. It provides
path-aware parsers, safe Result parsing, thrown SchemaError parsing, type
inference helpers, and inspectable definitions used by adapters.
import {
createSchema,
parseFailure,
parseSuccess,
schemaIssue,
} from "@lucid-softworks/schema-core";
const positive = createSchema<number, number>(
(input, path) =>
input > 0
? parseSuccess(input)
: parseFailure(schemaIssue("positive", "Must be positive", path)),
{ kind: "positive" },
);
positive.parse(1); // 1
positive.safeParse(-1); // Err<SchemaError>