bigbuffet-rw/packages/pl-api/lib/entities/rule.ts
marcin mikołajczak c618e1f619 Default to whatever content type is supported
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-21 20:39:23 +02:00

21 lines
455 B
TypeScript

import * as v from 'valibot';
const baseRuleSchema = v.object({
id: v.string(),
text: v.fallback(v.string(), ''),
hint: v.fallback(v.string(), ''),
});
/** @see {@link https://docs.joinmastodon.org/entities/Rule/} */
const ruleSchema = v.pipe(
v.any(),
v.transform((data: any) => ({
...data,
hint: data.hint || data.subtext,
})),
baseRuleSchema,
);
type Rule = v.InferOutput<typeof ruleSchema>;
export { ruleSchema, type Rule };