bigbuffet-rw/packages/pl-api/lib/entities/rule.ts
marcin mikołajczak 036fa32cd3 Add pl-api to workspace
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-28 13:43:23 +02:00

17 lines
401 B
TypeScript

import { z } from 'zod';
const baseRuleSchema = z.object({
id: z.string(),
text: z.string().catch(''),
hint: z.string().catch(''),
});
/** @see {@link https://docs.joinmastodon.org/entities/Rule/} */
const ruleSchema = z.preprocess((data: any) => ({
...data,
hint: data.hint || data.subtext,
}), baseRuleSchema);
type Rule = z.infer<typeof ruleSchema>;
export { ruleSchema, type Rule };