Variable v2Const

v2: ZodObject<{
    spec: ZodLiteral<"chara_card_v2">;
    spec_version: ZodString;
    data: ZodObject<{
        name: ZodString;
        description: ZodString;
        personality: ZodString;
        scenario: ZodString;
        first_mes: ZodString;
        mes_example: ZodString;
        creator_notes: ZodString;
        system_prompt: ZodString;
        post_history_instructions: ZodString;
        alternate_greetings: ZodArray<ZodString, "many">;
        character_book: ZodOptional<ZodObject<{
            name: ZodOptional<ZodString>;
            description: ZodOptional<ZodString>;
            scan_depth: ZodOptional<ZodNumber>;
            token_budget: ZodOptional<ZodNumber>;
            recursive_scanning: ZodOptional<ZodBoolean>;
            extensions: ZodRecord<ZodString, ZodAny>;
            entries: ZodArray<ZodObject<{
                keys: ZodArray<ZodString, "many">;
                content: ZodString;
                extensions: ZodRecord<ZodString, ZodAny>;
                enabled: ZodBoolean;
                insertion_order: ZodNumber;
                case_sensitive: ZodOptional<ZodBoolean>;
                name: ZodOptional<ZodString>;
                priority: ZodOptional<ZodNumber>;
                id: ZodOptional<ZodNumber>;
                comment: ZodOptional<ZodString>;
                selective: ZodOptional<ZodBoolean>;
                secondary_keys: ZodOptional<ZodArray<ZodString, "many">>;
                constant: ZodOptional<ZodBoolean>;
                position: ZodOptional<ZodUnion<[ZodLiteral<"before_char">, ZodLiteral<"after_char">]>>;
            }, "strip", ZodTypeAny, {
                keys: string[];
                content: string;
                extensions: Record<string, any>;
                enabled: boolean;
                insertion_order: number;
                case_sensitive?: boolean;
                name?: string;
                priority?: number;
                id?: number;
                comment?: string;
                selective?: boolean;
                secondary_keys?: string[];
                constant?: boolean;
                position?: "before_char" | "after_char";
            }, {
                keys: string[];
                content: string;
                extensions: Record<string, any>;
                enabled: boolean;
                insertion_order: number;
                case_sensitive?: boolean;
                name?: string;
                priority?: number;
                id?: number;
                comment?: string;
                selective?: boolean;
                secondary_keys?: string[];
                constant?: boolean;
                position?: "before_char" | "after_char";
            }>, "many">;
        }, "strip", ZodTypeAny, {
            name?: string;
            description?: string;
            scan_depth?: number;
            token_budget?: number;
            recursive_scanning?: boolean;
            extensions: Record<string, any>;
            entries: ({ keys: string[]; content: string; extensions: Record<string, any>; enabled: boolean; insertion_order: number; case_sensitive?: boolean | undefined; name?: string | undefined; priority?: number | undefined; ... 5 more ...; position?: "before_char" | ... 1 more ... | undefined; })[];
        }, {
            name?: string;
            description?: string;
            scan_depth?: number;
            token_budget?: number;
            recursive_scanning?: boolean;
            extensions: Record<string, any>;
            entries: ({ keys: string[]; content: string; extensions: Record<string, any>; enabled: boolean; insertion_order: number; case_sensitive?: boolean | undefined; name?: string | undefined; priority?: number | undefined; ... 5 more ...; position?: "before_char" | ... 1 more ... | undefined; })[];
        }>>;
        tags: ZodArray<ZodString, "many">;
        creator: ZodString;
        character_version: ZodString;
        extensions: ZodRecord<ZodString, ZodAny>;
    }, "strip", ZodTypeAny, {
        name: string;
        description: string;
        personality: string;
        scenario: string;
        first_mes: string;
        mes_example: string;
        creator_notes: string;
        system_prompt: string;
        post_history_instructions: string;
        alternate_greetings: string[];
        character_book?: {
            name?: string;
            description?: string;
            scan_depth?: number;
            token_budget?: number;
            recursive_scanning?: boolean;
            extensions: Record<string, any>;
            entries: ({ keys: string[]; content: string; extensions: Record<string, any>; enabled: boolean; insertion_order: number; case_sensitive?: boolean | undefined; name?: string | undefined; priority?: number | undefined; ... 5 more ...; position?: "before_char" | ... 1 more ... | undefined; })[];
        };
        tags: string[];
        creator: string;
        character_version: string;
        extensions: Record<string, any>;
    }, {
        name: string;
        description: string;
        personality: string;
        scenario: string;
        first_mes: string;
        mes_example: string;
        creator_notes: string;
        system_prompt: string;
        post_history_instructions: string;
        alternate_greetings: string[];
        character_book?: {
            name?: string;
            description?: string;
            scan_depth?: number;
            token_budget?: number;
            recursive_scanning?: boolean;
            extensions: Record<string, any>;
            entries: ({ keys: string[]; content: string; extensions: Record<string, any>; enabled: boolean; insertion_order: number; case_sensitive?: boolean | undefined; name?: string | undefined; priority?: number | undefined; ... 5 more ...; position?: "before_char" | ... 1 more ... | undefined; })[];
        };
        tags: string[];
        creator: string;
        character_version: string;
        extensions: Record<string, any>;
    }>;
}, "strip", ZodTypeAny, {
    spec: "chara_card_v2";
    spec_version: string;
    data: {
        name: string;
        description: string;
        personality: string;
        scenario: string;
        first_mes: string;
        mes_example: string;
        creator_notes: string;
        system_prompt: string;
        post_history_instructions: string;
        alternate_greetings: string[];
        character_book?: { entries: { keys: string[]; content: string; extensions: Record<string, any>; enabled: boolean; insertion_order: number; case_sensitive?: boolean | undefined; name?: string | undefined; ... 6 more ...; position?: "before_char" | ... 1 more ... | undefined; }[]; ... 5 more ...; recursive_scanning?: boolean | undefin...;
        tags: string[];
        creator: string;
        character_version: string;
        extensions: Record<string, any>;
    };
}, {
    spec: "chara_card_v2";
    spec_version: string;
    data: {
        name: string;
        description: string;
        personality: string;
        scenario: string;
        first_mes: string;
        mes_example: string;
        creator_notes: string;
        system_prompt: string;
        post_history_instructions: string;
        alternate_greetings: string[];
        character_book?: { entries: { keys: string[]; content: string; extensions: Record<string, any>; enabled: boolean; insertion_order: number; case_sensitive?: boolean | undefined; name?: string | undefined; ... 6 more ...; position?: "before_char" | ... 1 more ... | undefined; }[]; ... 5 more ...; recursive_scanning?: boolean | undefin...;
        tags: string[];
        creator: string;
        character_version: string;
        extensions: Record<string, any>;
    };
}> = ...

A parser object made with the zod library which can be used to validate or parse Character Cards using the V2 spec.

https://github.com/malfoyslastname/character-card-spec-v2/blob/main/spec_v2.md

Example

import * as Cards from 'character-card-utils'

// parsing
Cards.v2.parse(v2Card) //=> return type V2
Cards.v2.parse(v2CardWithV1FieldsBackfilled) //=> return type V2
Cards.v2.parse(incorrectlyFormattedCard) //=> throws ZodError
Cards.v2.parse(v1Card) //=> throws ZodError

// exception-free parsing
Cards.v1.safeParse(v1Card) // => return type { success: true; data: V2 }
Cards.v1.safeParse(v2CardWithV1FieldsBackfilled) //=> return type { success: true; data: V2 }
Cards.v1.safeParse(incorrectlyFormattedCard) //=> return type { success: false; error: ZodError }
Cards.v1.safeParse(v1Card) //=> return type { success: false; error: ZodError }

Generated using TypeDoc