import { type } from 'arktype';
const test = type({
foo: type("string.numeric.parse"),
bar: type("number"),
baz: type("string.date.iso.parse")
});
// bar is expected to fail
const out = test({ foo: '1', bar: "2", baz: "2011-10-05T14:48:00.000Z" });
if (out instanceof type.errors) {
// log errors to fix after the fact
// ctx is protected, but ctx.root is useful?
const partiallyParsed = out.ctx.root;
console.log("Partially parsed data", partiallyParsed);
}
import { type } from 'arktype';
const test = type({
foo: type("string.numeric.parse"),
bar: type("number"),
baz: type("string.date.iso.parse")
});
// bar is expected to fail
const out = test({ foo: '1', bar: "2", baz: "2011-10-05T14:48:00.000Z" });
if (out instanceof type.errors) {
// log errors to fix after the fact
// ctx is protected, but ctx.root is useful?
const partiallyParsed = out.ctx.root;
console.log("Partially parsed data", partiallyParsed);
}