Strata · API
checkCorpus
checkCorpus, from @niscorp/strata/check, upgrades every captured document from the stamp it was saved at and validates the result against its kind’s current schema. A snapshot comparison only detects that a schema changed; this reports whether documents that were saved still validate after the change. Here the same rename is checked without its migration and with it.
z.object({
text: z.string(),
tone: z.enum(['primary', 'quiet']).optional(),
}).strict()[
{
id: 'tonight, book seats',
document: { label: 'Book seats', tone: 'primary' },
},
{
id: 'my ticket, show it',
document: { label: 'Show my ticket' },
},
]{
withNoMigration: {
passed: 0,
failures: [
{
id: 'tonight, book seats',
kind: 'theatre.buttons/button',
reason: 'text: Invalid input: expected string, received undefined; Unrecognized key: "label"',
},
{
id: 'my ticket, show it',
kind: 'theatre.buttons/button',
reason: 'text: Invalid input: expected string, received undefined; Unrecognized key: "label"',
},
],
},
withTheMigration: { passed: 2, failures: [] },
}Runs in this page on the installed package. The input and the expected output are defined by the example.