Skip to content

Commit a1be24f

Browse files
authored
Merge pull request #25 from Maur025/add-zod-schema-type
chore: update version to 2.1.1 and add changelog entry for id validat…
2 parents bc7e504 + 82e64cb commit a1be24f

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

packages/core-model-data/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @maur025/core-model-data
22

3+
## 2.1.1
4+
5+
### Patch Changes
6+
7+
- fix validation from id, now convert all in string, expect null
8+
9+
## 2.1.0
10+
11+
### Minor Changes
12+
13+
- option to receive numbers was added, kepping the database ID field as a string
14+
315
## 2.0.2
416

517
### Patch Changes

packages/core-model-data/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@maur025/core-model-data",
3-
"version": "2.0.2",
3+
"version": "2.1.1",
44
"author": "maur025 <mmoyapalli@gmail.com>",
55
"description": "utility library to declare and extend the model data in Typescript.",
66
"license": "MIT",

packages/core-model-data/src/lib/zod/data/base-data.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import z, { boolean, object, string } from "zod/v4";
1+
import z, { boolean, object, preprocess, string } from "zod/v4";
22

33
export const BaseData = object({
4-
id: string().nonempty().optional(),
4+
id: preprocess((value) => {
5+
if (value == null) return undefined;
6+
7+
return String(value);
8+
}, string().nonempty()).optional(),
59
deleted: boolean().optional(),
610
});
711

0 commit comments

Comments
 (0)