@lucid-softworks/schema-transform
v0.1.0
Published
Refinement, transformation, preprocessing, defaults, and schema pipelines.
Maintainers
Readme
@lucid-softworks/schema-transform
Composable post-parse refinements, output transformations, input preprocessing, defaults, and schema pipelines.
import {
defaultSchema,
preprocessSchema,
refineSchema,
transformSchema,
} from "@lucid-softworks/schema-transform";
const positive = refineSchema(numberSchema(), (value) => value > 0, {
message: "Expected a positive number",
});
const port = preprocessSchema(Number, positive);
const trimmed = transformSchema(stringSchema(), (value) => value.trim());
const host = defaultSchema(stringSchema(), () => "localhost");Thrown preprocessing and transformation errors become structured schema issues. Defaults are factories so mutable default values can be created per parse.
