@mac777/project-pinecone-schema 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -137,14 +137,17 @@ exports.approvedEventEditSchema = zod_1.z.object({
137
137
  schedule: zod_1.z.object({
138
138
  startDate: zod_1.z.date(),
139
139
  endDate: zod_1.z.date()
140
- }).optional().refine(data => {
141
- if (!data?.startDate || !data?.endDate)
142
- return false;
143
- const diff = Math.abs(data?.startDate?.getTime() - data?.endDate?.getTime());
144
- return diff <= 2 * 60 * 60 * 1000;
145
- }, {
146
- message: 'Schedule must be within 2 hours of original',
147
- path: ['schedule', 'endDate']
140
+ }).optional().superRefine((data, ctx) => {
141
+ if (!data)
142
+ return;
143
+ const diff = Math.abs(data.startDate.getTime() - data.endDate.getTime());
144
+ if (diff > 2 * 60 * 60 * 1000) {
145
+ ctx.addIssue({
146
+ path: ['endDate'],
147
+ message: 'Schedule must be within 2 hours of original',
148
+ code: zod_1.z.ZodIssueCode.custom,
149
+ });
150
+ }
148
151
  })
149
152
  });
150
153
  // Published
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mac777/project-pinecone-schema",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -152,13 +152,20 @@ export const approvedEventEditSchema = z.object({
152
152
  schedule: z.object({
153
153
  startDate: z.date(),
154
154
  endDate: z.date()
155
- }).optional().refine(data => {
156
- if (!data?.startDate || !data?.endDate) return false;
157
- const diff = Math.abs(data?.startDate?.getTime() - data?.endDate?.getTime());
158
- return diff <= 2 * 60 * 60 * 1000;
159
- }, {
160
- message: 'Schedule must be within 2 hours of original',
161
- path: ['schedule', 'endDate']
155
+ }).optional().superRefine((data, ctx) => {
156
+ if (!data) return;
157
+
158
+ const diff = Math.abs(
159
+ data.startDate.getTime() - data.endDate.getTime()
160
+ );
161
+
162
+ if (diff > 2 * 60 * 60 * 1000) {
163
+ ctx.addIssue({
164
+ path: ['endDate'],
165
+ message: 'Schedule must be within 2 hours of original',
166
+ code: z.ZodIssueCode.custom,
167
+ });
168
+ }
162
169
  })
163
170
  });
164
171