Skip to content

Commit 46c1001

Browse files
committed
schema test
1 parent d941f40 commit 46c1001

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

parsed/classes/test-class-zod.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ClassSchema } from './5e-SRD-Classes'; // Adjust path as needed
2+
3+
const barbarianData = {
4+
index: "barbarian",
5+
name: "Barbarian",
6+
hit_die: 12,
7+
primary_ability: {
8+
desc: "Strength",
9+
all_of: [{ index: "str", name: "STR", url: "/api/2024/ability-scores/str" }]
10+
},
11+
class_levels: "/api/2024/classes/barbarian/levels",
12+
proficiency_choices: [],
13+
starting_equipment_options: [],
14+
url: "/api/2024/classes/barbarian"
15+
};
16+
17+
const result = ClassSchema.safeParse(barbarianData);
18+
19+
if (result.success) {
20+
console.log("✅ Schema is working perfectly!");
21+
} else {
22+
console.error("❌ Schema Validation Failed:");
23+
console.log(JSON.stringify(result.error.format(), null, 2));
24+
}

src/2024/schemas/5e-SRD-Classes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { z } from 'zod';
2-
import { APIReferenceSchema, ChoiceSchema } from '../../schemas/common';
2+
import { APIReferenceSchema, ChoiceSchema } from '../../src/schemas/common';
33

44
const SpellcastingInfoSchema = z.object({
55
name: z.string(),

0 commit comments

Comments
 (0)