Equivalent of z.function from zod in shapeshift?

The title describes the issue
Solution:
there is no function validation yet in sapphire. I tried to add it a month or so ago and I was following instructions from @vladdy and @kyra but I had no idea what they were describing or how to implement it. I think either of them could add it in an afternoon given not procrastinating on it but alas. The equivalent of safeParse is .run(data: unknown): Result: https://github.com/sapphiredev/shapeshift/#rundata-unknown-resultt-error-given-a-validation-you-can-call-this-method-to-check-whether-or-not-the which returns a Result on which you can call .isOk() / isErr() / .unwrap()...
Jump to solution
3 Replies
annalasko
annalasko5mo ago
Additionally, what is the equivalent of safeParse() and .success? This is the code I am trying to convert to its shapeshift equivalent:
export const schema = z.object({
data: z.record(z.any()),
execute: z.function(),
});

export const predicate: StructurePredicate<Command> = (structure: unknown): structure is Command =>
schema.safeParse(structure).success;
export const schema = z.object({
data: z.record(z.any()),
execute: z.function(),
});

export const predicate: StructurePredicate<Command> = (structure: unknown): structure is Command =>
schema.safeParse(structure).success;
Solution
Favna
Favna5mo ago
there is no function validation yet in sapphire. I tried to add it a month or so ago and I was following instructions from @vladdy and @kyra but I had no idea what they were describing or how to implement it. I think either of them could add it in an afternoon given not procrastinating on it but alas. The equivalent of safeParse is .run(data: unknown): Result: https://github.com/sapphiredev/shapeshift/#rundata-unknown-resultt-error-given-a-validation-you-can-call-this-method-to-check-whether-or-not-the which returns a Result on which you can call .isOk() / isErr() / .unwrap()
annalasko
annalasko5mo ago
Understood, thank you!
Want results from more Discord servers?
Add your server