Skip to content

Commit

Permalink
update: sponsor zod validation schema (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
samderanova authored Jan 14, 2024
1 parent 64c96fe commit 4ec096c
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions apps/site/src/app/(main)/(home)/sections/Sponsors/getSponsors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@ import { cache } from "react";
import { client } from "@/lib/sanity/client";
import { SanityDocument, SanityImageReference } from "@/lib/sanity/types";

export const Sponsor = z.object({
_type: z.literal("sponsor"),
_key: z.string(),
name: z.string(),
url: z.string().url().optional(),
tier: z.union([
z.literal("platinum"),
z.literal("gold"),
z.literal("bronze"),
z.literal("silver"),
z.literal("sponsored-prize"),
z.literal("in-kind"),
]),
logo: SanityImageReference,
});

const Sponsors = SanityDocument.extend({
sponsors: z.array(
z.object({
_type: z.literal("sponsor"),
_key: z.string(),
name: z.string(),
url: z.string().url().optional(),
tier: z.union([z.literal("bronze"), z.literal("silver")]),
logo: SanityImageReference,
}),
),
sponsors: z.array(Sponsor),
});

export const getSponsors = cache(async () => {
Expand Down

0 comments on commit 4ec096c

Please sign in to comment.