Skip to content

Commit

Permalink
Release drizzle-zod 0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dankochetov committed Mar 27, 2023
1 parent 60ad12c commit 09d1b8c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 20 deletions.
1 change: 1 addition & 0 deletions changelogs/drizzle-zod/0.1.4.md
@@ -0,0 +1 @@
- 馃悰 Updated logic for drizzle-orm 0.23.2
4 changes: 1 addition & 3 deletions drizzle-zod/README.md
Expand Up @@ -42,15 +42,13 @@ const newUserSchema = createInsertSchema(users, 'camel');

// Override the fields
const newUserSchema = createInsertSchema(users, {
// this is required for runtime validation of text enum types, otherwise z.string() will be used
role: z.enum(['admin', 'user']),
role: z.string(),
});

// Refine the fields
const newUserSchema = createInsertSchema(users, (schema) => ({
id: schema.id.positive(),
email: schema.email.email(),
role: z.enum(['admin', 'user']),
}));

const newUserSchema = createInsertSchema(users, 'snake', (schema) => ({
Expand Down
2 changes: 1 addition & 1 deletion drizzle-zod/package.json
@@ -1,6 +1,6 @@
{
"name": "drizzle-zod",
"version": "0.1.3",
"version": "0.1.4",
"description": "Generate Zod schemas from Drizzle ORM schemas",
"scripts": {
"build": "tsc && resolve-tspaths && cp README.md package.json dist/",
Expand Down
16 changes: 0 additions & 16 deletions drizzle-zod/tests/pg.test.ts
Expand Up @@ -39,22 +39,6 @@ test('users insert schema w/ enum', (t) => {
};
});

const test1 = createInsertSchema(users);
const test2 = createInsertSchema(users, 'camel');
const test3 = createInsertSchema(users, 'snake');
const test4 = createInsertSchema(users, {
roleText: z.enum(['admin', 'user']),
});
const test5 = createInsertSchema(users, 'camel', {
roleText: z.enum(['admin', 'user']),
});
const test6 = createInsertSchema(users, 'snake', {
role_text: z.enum(['admin', 'user']),
});
const test7 = createInsertSchema(users, 'snake', (schema) => ({
role_text: z.enum(['admin', 'user']),
}));

const expected = z.object({
id: z.number().positive().optional(),
name: z.string(),
Expand Down

0 comments on commit 09d1b8c

Please sign in to comment.