Skip to content

Commit

Permalink
feat(request): allow setting custom id schema for resource identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD committed May 4, 2024
1 parent 95da2ba commit 9838f5a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ const fixedTypeSchema = <TType extends string>(type: TType) =>

type ResourceIdentifierSchema<TType extends string> = z.ZodObject<{
type: z.ZodType<TType>;
id: z.ZodString;
id: z.ZodType<string>;
}>;

export const resourceIdentifierSchema = <TType extends string>(
type: TType,
idSchema: z.ZodType<string> = z.string(),
): ResourceIdentifierSchema<TType> =>
z.object({
type: fixedTypeSchema(type),
id: z.string(),
id: idSchema,
});

type ClientResourceIdentifierSchema<TType extends string> = z.ZodObject<{
Expand Down

0 comments on commit 9838f5a

Please sign in to comment.