bigbuffet-rw/packages/pl-api/lib/entities/rule.ts
marcin mikołajczak bc65755862 pl-api: Update docs
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-11-29 16:01:54 +01:00

27 lines
514 B
TypeScript

import * as v from 'valibot';
const baseRuleSchema = v.object({
id: v.string(),
text: v.fallback(v.string(), ''),
hint: v.fallback(v.string(), ''),
});
/**
* @category Schemas
* @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,
);
/**
* @category Entity types
*/
type Rule = v.InferOutput<typeof ruleSchema>;
export { ruleSchema, type Rule };