@careflair/common 1.0.31 → 1.0.33
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.
- package/dist/schemas/forms.d.ts +39 -8
- package/dist/schemas/forms.js +36 -7
- package/package.json +1 -1
package/dist/schemas/forms.d.ts
CHANGED
|
@@ -195,39 +195,70 @@ export declare const EducationAndTrainingFormSchema: z.ZodEffects<z.ZodEffects<z
|
|
|
195
195
|
/**
|
|
196
196
|
* Work history form schema
|
|
197
197
|
*/
|
|
198
|
-
export declare const WorkHistoryFormSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
198
|
+
export declare const WorkHistoryFormSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
199
199
|
jobTitle: z.ZodString;
|
|
200
200
|
organisation: z.ZodString;
|
|
201
201
|
startDate: z.ZodEffects<z.ZodString, string, string>;
|
|
202
|
-
endDate: z.ZodString
|
|
202
|
+
endDate: z.ZodOptional<z.ZodString>;
|
|
203
|
+
isCurrentlyWorking: z.ZodDefault<z.ZodBoolean>;
|
|
203
204
|
}, "strip", z.ZodTypeAny, {
|
|
204
205
|
startDate: string;
|
|
205
|
-
endDate: string;
|
|
206
206
|
jobTitle: string;
|
|
207
207
|
organisation: string;
|
|
208
|
+
isCurrentlyWorking: boolean;
|
|
209
|
+
endDate?: string | undefined;
|
|
208
210
|
}, {
|
|
209
211
|
startDate: string;
|
|
210
|
-
endDate: string;
|
|
211
212
|
jobTitle: string;
|
|
212
213
|
organisation: string;
|
|
214
|
+
endDate?: string | undefined;
|
|
215
|
+
isCurrentlyWorking?: boolean | undefined;
|
|
213
216
|
}>, {
|
|
214
217
|
startDate: string;
|
|
215
|
-
endDate: string;
|
|
216
218
|
jobTitle: string;
|
|
217
219
|
organisation: string;
|
|
220
|
+
isCurrentlyWorking: boolean;
|
|
221
|
+
endDate?: string | undefined;
|
|
218
222
|
}, {
|
|
219
223
|
startDate: string;
|
|
220
|
-
endDate: string;
|
|
221
224
|
jobTitle: string;
|
|
222
225
|
organisation: string;
|
|
226
|
+
endDate?: string | undefined;
|
|
227
|
+
isCurrentlyWorking?: boolean | undefined;
|
|
223
228
|
}>, {
|
|
224
229
|
startDate: string;
|
|
225
|
-
endDate: string;
|
|
226
230
|
jobTitle: string;
|
|
227
231
|
organisation: string;
|
|
232
|
+
isCurrentlyWorking: boolean;
|
|
233
|
+
endDate?: string | undefined;
|
|
228
234
|
}, {
|
|
229
235
|
startDate: string;
|
|
230
|
-
endDate: string;
|
|
231
236
|
jobTitle: string;
|
|
232
237
|
organisation: string;
|
|
238
|
+
endDate?: string | undefined;
|
|
239
|
+
isCurrentlyWorking?: boolean | undefined;
|
|
240
|
+
}>, {
|
|
241
|
+
startDate: string;
|
|
242
|
+
jobTitle: string;
|
|
243
|
+
organisation: string;
|
|
244
|
+
isCurrentlyWorking: boolean;
|
|
245
|
+
endDate?: string | undefined;
|
|
246
|
+
}, {
|
|
247
|
+
startDate: string;
|
|
248
|
+
jobTitle: string;
|
|
249
|
+
organisation: string;
|
|
250
|
+
endDate?: string | undefined;
|
|
251
|
+
isCurrentlyWorking?: boolean | undefined;
|
|
252
|
+
}>, {
|
|
253
|
+
startDate: string;
|
|
254
|
+
jobTitle: string;
|
|
255
|
+
organisation: string;
|
|
256
|
+
isCurrentlyWorking: boolean;
|
|
257
|
+
endDate?: string | undefined;
|
|
258
|
+
}, {
|
|
259
|
+
startDate: string;
|
|
260
|
+
jobTitle: string;
|
|
261
|
+
organisation: string;
|
|
262
|
+
endDate?: string | undefined;
|
|
263
|
+
isCurrentlyWorking?: boolean | undefined;
|
|
233
264
|
}>;
|
package/dist/schemas/forms.js
CHANGED
|
@@ -185,21 +185,50 @@ exports.WorkHistoryFormSchema = zod_1.z
|
|
|
185
185
|
.refine((date) => !isDateInFuture(date), {
|
|
186
186
|
message: "Start date cannot be in the future",
|
|
187
187
|
}),
|
|
188
|
-
endDate: zod_1.z.string().
|
|
188
|
+
endDate: zod_1.z.string().optional(),
|
|
189
|
+
isCurrentlyWorking: zod_1.z.boolean().default(false),
|
|
189
190
|
})
|
|
190
191
|
.refine((data) => {
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
// If endDate is provided, validate it's after start date
|
|
193
|
+
if (data.endDate && data.endDate.length > 0) {
|
|
194
|
+
const startDate = new Date(data.startDate);
|
|
195
|
+
const endDate = new Date(data.endDate);
|
|
196
|
+
return endDate > startDate;
|
|
197
|
+
}
|
|
198
|
+
return true;
|
|
195
199
|
}, {
|
|
196
200
|
message: "End date must be after start date",
|
|
197
201
|
path: ["endDate"],
|
|
198
202
|
})
|
|
199
203
|
.refine((data) => {
|
|
200
|
-
//
|
|
201
|
-
|
|
204
|
+
// If endDate is provided, validate it's not in the future
|
|
205
|
+
if (data.endDate && data.endDate.length > 0) {
|
|
206
|
+
return !isDateInFuture(data.endDate);
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
209
|
+
}, {
|
|
210
|
+
message: "End date cannot be in the future",
|
|
211
|
+
path: ["endDate"],
|
|
212
|
+
})
|
|
213
|
+
.refine((data) => {
|
|
214
|
+
// If endDate is provided, validate there's at least 1 month difference
|
|
215
|
+
if (data.endDate && data.endDate.length > 0) {
|
|
216
|
+
return isAtLeastOneMonthDifference(data.startDate, data.endDate);
|
|
217
|
+
}
|
|
218
|
+
return true;
|
|
202
219
|
}, {
|
|
203
220
|
message: "There must be at least 1 month between start and end date",
|
|
204
221
|
path: ["endDate"],
|
|
222
|
+
})
|
|
223
|
+
.refine((data) => {
|
|
224
|
+
// If there is an endDate, isCurrentlyWorking must be false
|
|
225
|
+
// If isCurrentlyWorking is false, endDate must be provided
|
|
226
|
+
if (data.endDate && data.endDate.length > 0) {
|
|
227
|
+
return !data.isCurrentlyWorking;
|
|
228
|
+
}
|
|
229
|
+
// If no endDate, isCurrentlyWorking must be true
|
|
230
|
+
return data.isCurrentlyWorking;
|
|
231
|
+
}, {
|
|
232
|
+
message: "If there is an endDate, Currently Working must be false. If Currently Working is false, endDate must be provided.",
|
|
233
|
+
path: ["endDate", "isCurrentlyWorking"],
|
|
205
234
|
});
|