refactor(lib): remove keys and just get a slug from the label
This commit is contained in:
parent
7dc4bd8a11
commit
456e7e8feb
5 changed files with 26 additions and 30 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { z } from 'zod';
|
||||
import type { FieldDef, Template } from './types';
|
||||
import { slugify } from './utils/slugify';
|
||||
|
||||
function zodForField(field: FieldDef): z.ZodTypeAny {
|
||||
switch (field.type) {
|
||||
|
|
@ -29,7 +30,7 @@ export function buildCharacterSchema(template: Template): z.ZodObject<Record<str
|
|||
const shape: Record<string, z.ZodTypeAny> = {};
|
||||
for (const record of template.records) {
|
||||
for (const field of record.fields) {
|
||||
shape[field.key] = zodForField(field);
|
||||
shape[slugify(field.label)] = zodForField(field);
|
||||
}
|
||||
}
|
||||
return z.object(shape).partial();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue