arktypea
arktype•13mo ago•
12 replies
Raqueebuddin Aziz

is there a mustNotBe

currently I am using this as a workaround but I'd rather not implement the (was actual) part myself
I would like maybe a mustNotBe or maybe a problem variant that doesn't overwrite the was stuff in the error string
const formSchema = type({
    name: type('string.trim').narrow((name, ctx) => {
        if (!name.endsWith('.project')) return true;
        return ctx.reject({
            problem: `cannot end with .project (was "${name}")`
        });
    }),
    id: type('string | undefined').pipe((v) => v ?? nanoid()),
    parentId: type('string')
});


Thanks for any help 🙂
Was this page helpful?