@careflair/common 1.0.26 → 1.0.28

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.
@@ -125,42 +125,72 @@ 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.ZodObject<{
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.ZodEffects<z.ZodEffects<z.ZodObject<{
129
+ type: z.ZodString;
139
130
  school: z.ZodString;
140
131
  degree: z.ZodString;
141
- startDate: z.ZodDate;
142
- endDate: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
143
- isCurrentlyStudying: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<false>]>>;
132
+ startDate: z.ZodOptional<z.ZodDate>;
133
+ endDate: z.ZodOptional<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
- startDate: Date;
152
- endDate?: Date | null | undefined;
153
- isCurrentlyStudying?: boolean | undefined;
138
+ startDate?: Date | undefined;
139
+ endDate?: Date | undefined;
154
140
  }, {
155
- type: {
156
- value: string;
157
- label: string;
158
- };
141
+ type: string;
142
+ school: string;
143
+ degree: string;
144
+ startDate?: Date | undefined;
145
+ endDate?: Date | undefined;
146
+ }>, {
147
+ type: string;
148
+ school: string;
149
+ degree: string;
150
+ startDate?: Date | undefined;
151
+ endDate?: Date | undefined;
152
+ }, {
153
+ type: string;
154
+ school: string;
155
+ degree: string;
156
+ startDate?: Date | undefined;
157
+ endDate?: Date | undefined;
158
+ }>, {
159
+ type: string;
160
+ school: string;
161
+ degree: string;
162
+ startDate?: Date | undefined;
163
+ endDate?: Date | undefined;
164
+ }, {
165
+ type: string;
166
+ school: string;
167
+ degree: string;
168
+ startDate?: Date | undefined;
169
+ endDate?: Date | undefined;
170
+ }>, {
171
+ type: string;
172
+ school: string;
173
+ degree: string;
174
+ startDate?: Date | undefined;
175
+ endDate?: Date | undefined;
176
+ }, {
177
+ type: string;
178
+ school: string;
179
+ degree: string;
180
+ startDate?: Date | undefined;
181
+ endDate?: Date | undefined;
182
+ }>, {
183
+ type: string;
184
+ school: string;
185
+ degree: string;
186
+ startDate?: Date | undefined;
187
+ endDate?: Date | undefined;
188
+ }, {
189
+ type: string;
159
190
  school: string;
160
191
  degree: string;
161
- startDate: Date;
162
- endDate?: Date | null | undefined;
163
- isCurrentlyStudying?: boolean | undefined;
192
+ startDate?: Date | undefined;
193
+ endDate?: Date | undefined;
164
194
  }>;
165
195
  /**
166
196
  * Work history form schema
@@ -169,42 +199,35 @@ export declare const WorkHistoryFormSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
169
199
  jobTitle: z.ZodString;
170
200
  organisation: z.ZodString;
171
201
  startDate: z.ZodEffects<z.ZodString, string, string>;
172
- endDate: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
173
- isCurrentlyWorking: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
202
+ endDate: z.ZodString;
174
203
  }, "strip", z.ZodTypeAny, {
175
204
  startDate: string;
205
+ endDate: string;
176
206
  jobTitle: string;
177
207
  organisation: string;
178
- endDate?: string | undefined;
179
- isCurrentlyWorking?: boolean | undefined;
180
208
  }, {
181
209
  startDate: string;
210
+ endDate: string;
182
211
  jobTitle: string;
183
212
  organisation: string;
184
- endDate?: string | undefined;
185
- isCurrentlyWorking?: boolean | undefined;
186
213
  }>, {
187
214
  startDate: string;
215
+ endDate: string;
188
216
  jobTitle: string;
189
217
  organisation: string;
190
- endDate?: string | undefined;
191
- isCurrentlyWorking?: boolean | undefined;
192
218
  }, {
193
219
  startDate: string;
220
+ endDate: string;
194
221
  jobTitle: string;
195
222
  organisation: string;
196
- endDate?: string | undefined;
197
- isCurrentlyWorking?: boolean | undefined;
198
223
  }>, {
199
224
  startDate: string;
225
+ endDate: string;
200
226
  jobTitle: string;
201
227
  organisation: string;
202
- endDate?: string | undefined;
203
- isCurrentlyWorking?: boolean | undefined;
204
228
  }, {
205
229
  startDate: string;
230
+ endDate: string;
206
231
  jobTitle: string;
207
232
  organisation: string;
208
- endDate?: string | undefined;
209
- isCurrentlyWorking?: boolean | undefined;
210
233
  }>;
@@ -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.object({
100
- type: zod_1.z.object({
101
- label: zod_1.z.string(),
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")
@@ -109,11 +107,48 @@ exports.EducationAndTrainingFormSchema = zod_1.z.object({
109
107
  .string()
110
108
  .min(1, "Degree is required")
111
109
  .max(limits_1.EDUTRAINING_DEGREE_MAX_LENGTH, "Degree is too long"),
112
- startDate: zod_1.z.date({
113
- required_error: "Start date is required",
114
- }),
115
- endDate: zod_1.z.date().optional().nullable(),
116
- isCurrentlyStudying: zod_1.z.boolean().or(zod_1.z.literal(false)).optional(),
110
+ startDate: zod_1.z
111
+ .date({
112
+ invalid_type_error: "Please select a start date",
113
+ })
114
+ .optional(),
115
+ endDate: zod_1.z
116
+ .date({
117
+ invalid_type_error: "Please select an end date",
118
+ })
119
+ .optional(),
120
+ })
121
+ .refine((data) => data.startDate !== undefined && data.startDate !== null, {
122
+ message: "Start date is required",
123
+ path: ["startDate"],
124
+ })
125
+ .refine((data) => data.endDate !== undefined && data.endDate !== null, {
126
+ message: "End date is required",
127
+ path: ["endDate"],
128
+ })
129
+ .refine((data) => {
130
+ // Check if end date is after start date
131
+ const startDate = data.startDate;
132
+ const endDate = data.endDate;
133
+ if (!startDate || !endDate)
134
+ return true; // Skip if dates are not set yet
135
+ return endDate > startDate;
136
+ }, {
137
+ message: "End date must be after start date",
138
+ path: ["endDate"],
139
+ })
140
+ .refine((data) => {
141
+ // Check if there's at least 1 month difference
142
+ const startDate = data.startDate;
143
+ const endDate = data.endDate;
144
+ if (!startDate || !endDate)
145
+ return true; // Skip if dates are not set yet
146
+ const diffInMonths = (endDate.getFullYear() - startDate.getFullYear()) * 12 +
147
+ (endDate.getMonth() - startDate.getMonth());
148
+ return diffInMonths >= 1;
149
+ }, {
150
+ message: "There must be at least 1 month between start and end date",
151
+ path: ["endDate"],
117
152
  });
118
153
  // Helper function to check if date is in the future
119
154
  const isDateInFuture = (date) => {
@@ -150,18 +185,9 @@ exports.WorkHistoryFormSchema = zod_1.z
150
185
  .refine((date) => !isDateInFuture(date), {
151
186
  message: "Start date cannot be in the future",
152
187
  }),
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(),
188
+ endDate: zod_1.z.string().min(1, "End date is required"),
160
189
  })
161
190
  .refine((data) => {
162
- // Skip validation if currently working or no end date
163
- if (data.isCurrentlyWorking || !data.endDate)
164
- return true;
165
191
  // Check if end date is after start date
166
192
  const startDate = new Date(data.startDate);
167
193
  const endDate = new Date(data.endDate);
@@ -171,9 +197,6 @@ exports.WorkHistoryFormSchema = zod_1.z
171
197
  path: ["endDate"],
172
198
  })
173
199
  .refine((data) => {
174
- // Skip validation if currently working or no end date
175
- if (data.isCurrentlyWorking || !data.endDate)
176
- return true;
177
200
  // Check if there's at least 1 month difference
178
201
  return isAtLeastOneMonthDifference(data.startDate, data.endDate);
179
202
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@careflair/common",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "Shared assets for CareFlair",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",