All files / src/Infrastructure/ExternalService/Pokemon types.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 0/0
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 282x   2x         2x               2x                        
import * as z from "zod";
 
const NamedAPIResource = z.object({
    name: z.string(),
    url: z.string(),
});
 
const FlavorText = z.object({
    flavor_text: z.string(),
    language: NamedAPIResource,
});
 
/**
 * Zod schema for validating Pokemon species data from the API
 */
export const PokemonSpecies = z.object({
    id: z.number(),
    name: z.string(),
    is_legendary: z.boolean(),
    habitat: NamedAPIResource.optional(),
    flavor_text_entries: z.array(FlavorText),
});
 
/**
 * Type definition for Pokemon species data, inferred from the Zod schema
 */
export type PokemonSpecies = z.infer<typeof PokemonSpecies>;