Partial parse
Once in a while we encounter some data that's been stored away and the schema has changed over time. I'd like to parse it but also be forgiving enough to return the partially parsed schema. Something like this:
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);
}