Add tagSchema

This commit is contained in:
Alex Gleason 2023-05-03 13:40:30 -05:00
parent d4ed442a7e
commit f48edfba45
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 19 additions and 0 deletions

View file

@ -8,6 +8,7 @@ export { groupRelationshipSchema, type GroupRelationship } from './group-relatio
export { groupTagSchema, type GroupTag } from './group-tag';
export { pollSchema, type Poll, type PollOption } from './poll';
export { relationshipSchema, type Relationship } from './relationship';
export { tagSchema, type Tag } from './tag';
// Soapbox
export { adSchema, type Ad } from './soapbox/ad';

View file

@ -0,0 +1,18 @@
import { z } from 'zod';
const historySchema = z.object({
accounts: z.coerce.number(),
uses: z.coerce.number(),
});
/** // https://docs.joinmastodon.org/entities/tag */
const tagSchema = z.object({
name: z.string().min(1),
url: z.string().url().catch(''),
history: z.array(historySchema).nullable().catch(null),
following: z.boolean().catch(false),
});
type Tag = z.infer<typeof tagSchema>;
export { tagSchema, type Tag };