@careflair/common 1.0.26 → 1.0.27
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 +38 -39
- package/dist/schemas/forms.js +23 -20
- package/package.json +1 -1
package/dist/schemas/forms.d.ts
CHANGED
|
@@ -125,42 +125,48 @@ export declare const ContactDetailsFormSchema: z.ZodObject<{
|
|
|
125
125
|
/**
|
|
126
126
|
* Education and training form schema
|
|
127
127
|
*/
|
|
128
|
-
export declare const EducationAndTrainingFormSchema: z.ZodObject<{
|
|
129
|
-
type: z.
|
|
130
|
-
label: z.ZodString;
|
|
131
|
-
value: z.ZodString;
|
|
132
|
-
}, "strip", z.ZodTypeAny, {
|
|
133
|
-
value: string;
|
|
134
|
-
label: string;
|
|
135
|
-
}, {
|
|
136
|
-
value: string;
|
|
137
|
-
label: string;
|
|
138
|
-
}>;
|
|
128
|
+
export declare const EducationAndTrainingFormSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
129
|
+
type: z.ZodString;
|
|
139
130
|
school: z.ZodString;
|
|
140
131
|
degree: z.ZodString;
|
|
141
132
|
startDate: z.ZodDate;
|
|
142
|
-
endDate: z.
|
|
143
|
-
isCurrentlyStudying: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<false>]>>;
|
|
133
|
+
endDate: z.ZodDate;
|
|
144
134
|
}, "strip", z.ZodTypeAny, {
|
|
145
|
-
type:
|
|
146
|
-
value: string;
|
|
147
|
-
label: string;
|
|
148
|
-
};
|
|
135
|
+
type: string;
|
|
149
136
|
school: string;
|
|
150
137
|
degree: string;
|
|
151
138
|
startDate: Date;
|
|
152
|
-
endDate
|
|
153
|
-
isCurrentlyStudying?: boolean | undefined;
|
|
139
|
+
endDate: Date;
|
|
154
140
|
}, {
|
|
155
|
-
type:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
141
|
+
type: string;
|
|
142
|
+
school: string;
|
|
143
|
+
degree: string;
|
|
144
|
+
startDate: Date;
|
|
145
|
+
endDate: Date;
|
|
146
|
+
}>, {
|
|
147
|
+
type: string;
|
|
148
|
+
school: string;
|
|
149
|
+
degree: string;
|
|
150
|
+
startDate: Date;
|
|
151
|
+
endDate: Date;
|
|
152
|
+
}, {
|
|
153
|
+
type: string;
|
|
154
|
+
school: string;
|
|
155
|
+
degree: string;
|
|
156
|
+
startDate: Date;
|
|
157
|
+
endDate: Date;
|
|
158
|
+
}>, {
|
|
159
|
+
type: string;
|
|
160
|
+
school: string;
|
|
161
|
+
degree: string;
|
|
162
|
+
startDate: Date;
|
|
163
|
+
endDate: Date;
|
|
164
|
+
}, {
|
|
165
|
+
type: string;
|
|
159
166
|
school: string;
|
|
160
167
|
degree: string;
|
|
161
168
|
startDate: Date;
|
|
162
|
-
endDate
|
|
163
|
-
isCurrentlyStudying?: boolean | undefined;
|
|
169
|
+
endDate: Date;
|
|
164
170
|
}>;
|
|
165
171
|
/**
|
|
166
172
|
* Work history form schema
|
|
@@ -169,42 +175,35 @@ export declare const WorkHistoryFormSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
169
175
|
jobTitle: z.ZodString;
|
|
170
176
|
organisation: z.ZodString;
|
|
171
177
|
startDate: z.ZodEffects<z.ZodString, string, string>;
|
|
172
|
-
endDate: z.
|
|
173
|
-
isCurrentlyWorking: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
178
|
+
endDate: z.ZodString;
|
|
174
179
|
}, "strip", z.ZodTypeAny, {
|
|
175
180
|
startDate: string;
|
|
181
|
+
endDate: string;
|
|
176
182
|
jobTitle: string;
|
|
177
183
|
organisation: string;
|
|
178
|
-
endDate?: string | undefined;
|
|
179
|
-
isCurrentlyWorking?: boolean | undefined;
|
|
180
184
|
}, {
|
|
181
185
|
startDate: string;
|
|
186
|
+
endDate: string;
|
|
182
187
|
jobTitle: string;
|
|
183
188
|
organisation: string;
|
|
184
|
-
endDate?: string | undefined;
|
|
185
|
-
isCurrentlyWorking?: boolean | undefined;
|
|
186
189
|
}>, {
|
|
187
190
|
startDate: string;
|
|
191
|
+
endDate: string;
|
|
188
192
|
jobTitle: string;
|
|
189
193
|
organisation: string;
|
|
190
|
-
endDate?: string | undefined;
|
|
191
|
-
isCurrentlyWorking?: boolean | undefined;
|
|
192
194
|
}, {
|
|
193
195
|
startDate: string;
|
|
196
|
+
endDate: string;
|
|
194
197
|
jobTitle: string;
|
|
195
198
|
organisation: string;
|
|
196
|
-
endDate?: string | undefined;
|
|
197
|
-
isCurrentlyWorking?: boolean | undefined;
|
|
198
199
|
}>, {
|
|
199
200
|
startDate: string;
|
|
201
|
+
endDate: string;
|
|
200
202
|
jobTitle: string;
|
|
201
203
|
organisation: string;
|
|
202
|
-
endDate?: string | undefined;
|
|
203
|
-
isCurrentlyWorking?: boolean | undefined;
|
|
204
204
|
}, {
|
|
205
205
|
startDate: string;
|
|
206
|
+
endDate: string;
|
|
206
207
|
jobTitle: string;
|
|
207
208
|
organisation: string;
|
|
208
|
-
endDate?: string | undefined;
|
|
209
|
-
isCurrentlyWorking?: boolean | undefined;
|
|
210
209
|
}>;
|
package/dist/schemas/forms.js
CHANGED
|
@@ -96,11 +96,9 @@ exports.ContactDetailsFormSchema = zod_1.z.object({
|
|
|
96
96
|
/**
|
|
97
97
|
* Education and training form schema
|
|
98
98
|
*/
|
|
99
|
-
exports.EducationAndTrainingFormSchema = zod_1.z
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
value: zod_1.z.string(),
|
|
103
|
-
}),
|
|
99
|
+
exports.EducationAndTrainingFormSchema = zod_1.z
|
|
100
|
+
.object({
|
|
101
|
+
type: zod_1.z.string().min(1, "Type is required"),
|
|
104
102
|
school: zod_1.z
|
|
105
103
|
.string()
|
|
106
104
|
.min(1, "School/Instituation is required")
|
|
@@ -112,8 +110,25 @@ exports.EducationAndTrainingFormSchema = zod_1.z.object({
|
|
|
112
110
|
startDate: zod_1.z.date({
|
|
113
111
|
required_error: "Start date is required",
|
|
114
112
|
}),
|
|
115
|
-
endDate: zod_1.z.date(
|
|
116
|
-
|
|
113
|
+
endDate: zod_1.z.date({
|
|
114
|
+
required_error: "End date is required",
|
|
115
|
+
}),
|
|
116
|
+
})
|
|
117
|
+
.refine((data) => {
|
|
118
|
+
// Check if end date is after start date
|
|
119
|
+
return data.endDate > data.startDate;
|
|
120
|
+
}, {
|
|
121
|
+
message: "End date must be after start date",
|
|
122
|
+
path: ["endDate"],
|
|
123
|
+
})
|
|
124
|
+
.refine((data) => {
|
|
125
|
+
// Check if there's at least 1 month difference
|
|
126
|
+
const diffInMonths = (data.endDate.getFullYear() - data.startDate.getFullYear()) * 12 +
|
|
127
|
+
(data.endDate.getMonth() - data.startDate.getMonth());
|
|
128
|
+
return diffInMonths >= 1;
|
|
129
|
+
}, {
|
|
130
|
+
message: "There must be at least 1 month between start and end date",
|
|
131
|
+
path: ["endDate"],
|
|
117
132
|
});
|
|
118
133
|
// Helper function to check if date is in the future
|
|
119
134
|
const isDateInFuture = (date) => {
|
|
@@ -150,18 +165,9 @@ exports.WorkHistoryFormSchema = zod_1.z
|
|
|
150
165
|
.refine((date) => !isDateInFuture(date), {
|
|
151
166
|
message: "Start date cannot be in the future",
|
|
152
167
|
}),
|
|
153
|
-
endDate: zod_1.z
|
|
154
|
-
.string()
|
|
155
|
-
.optional()
|
|
156
|
-
.refine((date) => !date || !isDateInFuture(date), {
|
|
157
|
-
message: "End date cannot be in the future",
|
|
158
|
-
}),
|
|
159
|
-
isCurrentlyWorking: zod_1.z.boolean().default(false).optional(),
|
|
168
|
+
endDate: zod_1.z.string().min(1, "End date is required"),
|
|
160
169
|
})
|
|
161
170
|
.refine((data) => {
|
|
162
|
-
// Skip validation if currently working or no end date
|
|
163
|
-
if (data.isCurrentlyWorking || !data.endDate)
|
|
164
|
-
return true;
|
|
165
171
|
// Check if end date is after start date
|
|
166
172
|
const startDate = new Date(data.startDate);
|
|
167
173
|
const endDate = new Date(data.endDate);
|
|
@@ -171,9 +177,6 @@ exports.WorkHistoryFormSchema = zod_1.z
|
|
|
171
177
|
path: ["endDate"],
|
|
172
178
|
})
|
|
173
179
|
.refine((data) => {
|
|
174
|
-
// Skip validation if currently working or no end date
|
|
175
|
-
if (data.isCurrentlyWorking || !data.endDate)
|
|
176
|
-
return true;
|
|
177
180
|
// Check if there's at least 1 month difference
|
|
178
181
|
return isAtLeastOneMonthDifference(data.startDate, data.endDate);
|
|
179
182
|
}, {
|