@careflair/common 1.0.4 → 1.0.6

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.
Files changed (47) hide show
  1. package/dist/constants/index.d.ts +78 -0
  2. package/dist/constants/index.js +102 -13
  3. package/dist/index.d.ts +8 -7
  4. package/dist/index.js +23 -19
  5. package/dist/interfaces/common-fields.input.d.ts +15 -15
  6. package/dist/interfaces/common-fields.input.js +2 -2
  7. package/dist/interfaces/common-fields.output.d.ts +26 -26
  8. package/dist/interfaces/common-fields.output.js +2 -2
  9. package/dist/interfaces/index.d.ts +0 -0
  10. package/dist/interfaces/index.js +1 -0
  11. package/dist/schemas/availabilitySchemaValidation.d.ts +56 -56
  12. package/dist/schemas/availabilitySchemaValidation.js +79 -79
  13. package/dist/schemas/businessServicesValidation.d.ts +6 -6
  14. package/dist/schemas/businessServicesValidation.js +23 -23
  15. package/dist/schemas/educationSchemas.d.ts +38 -38
  16. package/dist/schemas/educationSchemas.js +29 -29
  17. package/dist/schemas/forms.d.ts +210 -0
  18. package/dist/schemas/forms.js +192 -0
  19. package/dist/schemas/hourlyRateSchemaValidation.d.ts +36 -36
  20. package/dist/schemas/hourlyRateSchemaValidation.js +25 -25
  21. package/dist/schemas/index.d.ts +2 -6
  22. package/dist/schemas/index.js +18 -16
  23. package/dist/schemas/userValiationSchema.d.ts +30 -30
  24. package/dist/schemas/userValiationSchema.js +38 -38
  25. package/dist/schemas/validation.d.ts +33 -0
  26. package/dist/schemas/validation.js +38 -0
  27. package/dist/schemas/workHistorySchema.d.ts +33 -33
  28. package/dist/schemas/workHistorySchema.js +28 -28
  29. package/dist/utils/date.d.ts +35 -0
  30. package/dist/utils/date.js +166 -0
  31. package/dist/utils/debounce.d.ts +8 -0
  32. package/dist/utils/debounce.js +22 -0
  33. package/dist/utils/enum.d.ts +6 -0
  34. package/dist/utils/enum.js +9 -0
  35. package/dist/utils/index.d.ts +6 -0
  36. package/dist/utils/index.js +28 -0
  37. package/dist/utils/phone.d.ts +9 -0
  38. package/dist/utils/phone.js +52 -0
  39. package/dist/utils/time.d.ts +63 -0
  40. package/dist/utils/time.js +134 -0
  41. package/dist/utils/utils.d.ts +6 -6
  42. package/dist/utils/utils.js +9 -9
  43. package/dist/utils/video.d.ts +25 -0
  44. package/dist/utils/video.js +80 -0
  45. package/dist/utils/videoValidation.d.ts +31 -31
  46. package/dist/utils/videoValidation.js +119 -119
  47. package/package.json +81 -46
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkHistoryFormSchema = exports.EducationAndTrainingFormSchema = exports.ContactDetailsFormSchema = exports.participantLocationFormSchema = exports.registrationFormSchema = void 0;
4
+ const libphonenumber_js_1 = require("libphonenumber-js");
5
+ const zod_1 = require("zod");
6
+ const limits_1 = require("../constants/limits");
7
+ const enums_1 = require("../enums");
8
+ const validation_1 = require("./validation");
9
+ /**
10
+ * Registration form schema
11
+ */
12
+ exports.registrationFormSchema = zod_1.z
13
+ .object({
14
+ firstName: zod_1.z
15
+ .string()
16
+ .min(1, "First name is required")
17
+ .min(limits_1.NAME_MIN_LENGTH, `First name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
18
+ .max(limits_1.NAME_MAX_LENGTH, `First name must be under ${limits_1.NAME_MAX_LENGTH} characters`),
19
+ lastName: zod_1.z
20
+ .string()
21
+ .min(1, "Last name is required")
22
+ .min(limits_1.NAME_MIN_LENGTH, `Last name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
23
+ .max(limits_1.NAME_MAX_LENGTH, `Last name must be under ${limits_1.NAME_MAX_LENGTH} characters`),
24
+ email: validation_1.emailSchema,
25
+ username: zod_1.z
26
+ .string()
27
+ .min(1, "Username is required")
28
+ .min(limits_1.USERNAME_MIN_LENGTH, `Username must be at least ${limits_1.USERNAME_MIN_LENGTH} characters long`)
29
+ .max(limits_1.USERNAME_MAX_LENGTH, `Username must be under ${limits_1.USERNAME_MAX_LENGTH} characters`)
30
+ .regex(/^[a-zA-Z0-9_]+$/, "Username can only contain letters, numbers, and underscores")
31
+ .refine((value) => !value.startsWith("_"), "Username cannot start with an underscore")
32
+ .refine((value) => !value.endsWith("_"), "Username cannot end with an underscore")
33
+ .refine((value) => !value.includes("__"), "Username cannot contain consecutive underscores"),
34
+ role: zod_1.z
35
+ .string()
36
+ .min(1, "Please select your role")
37
+ .refine((val) => Object.values(enums_1.UserRole).includes(val), {
38
+ message: "Please select a valid role",
39
+ }),
40
+ password: validation_1.passwordSchema,
41
+ confirmPassword: zod_1.z.string().min(1, "Confirm password is required"),
42
+ fingerPrint: zod_1.z.string().optional(),
43
+ })
44
+ // Password match validation
45
+ .refine((data) => data.password === data.confirmPassword, {
46
+ message: "Passwords don't match",
47
+ path: ["confirmPassword"],
48
+ });
49
+ /**
50
+ * Participant location form schema
51
+ */
52
+ exports.participantLocationFormSchema = zod_1.z.object({
53
+ address: zod_1.z
54
+ .object({
55
+ value: zod_1.z.string(),
56
+ label: zod_1.z.string(),
57
+ })
58
+ .refine((data) => data.value && data.label, {
59
+ message: "Address is required",
60
+ path: ["value"],
61
+ }),
62
+ state: zod_1.z
63
+ .object({
64
+ value: zod_1.z.string(),
65
+ label: zod_1.z.string(),
66
+ })
67
+ .refine((data) => data.value && data.label, {
68
+ message: "State is required",
69
+ path: ["value"],
70
+ }),
71
+ });
72
+ /**
73
+ * Contact details form schema
74
+ */
75
+ exports.ContactDetailsFormSchema = zod_1.z.object({
76
+ phone: zod_1.z
77
+ .string()
78
+ .refine((value) => {
79
+ if (!value)
80
+ return true; // Allow empty
81
+ // Validate it's Australian and mobile
82
+ if (!(0, libphonenumber_js_1.isValidPhoneNumber)(value, "AU"))
83
+ return false;
84
+ const parsed = (0, libphonenumber_js_1.parsePhoneNumberFromString)(value, "AU");
85
+ if (!parsed || parsed.country !== "AU")
86
+ return false;
87
+ const type = parsed.getType();
88
+ return type === "MOBILE" || type === "FIXED_LINE_OR_MOBILE";
89
+ }, {
90
+ message: "Please enter a valid Australian mobile number (04XX XXX XXX)",
91
+ })
92
+ .optional()
93
+ .or(zod_1.z.literal("")),
94
+ email: zod_1.z
95
+ .string()
96
+ .email("Invalid email address")
97
+ .optional()
98
+ .or(zod_1.z.literal("")),
99
+ website: zod_1.z
100
+ .string()
101
+ .regex(/^(?:https?:\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?$/, "Invalid URL")
102
+ .optional()
103
+ .or(zod_1.z.literal("")),
104
+ enableSmsNotifications: zod_1.z.boolean().optional(),
105
+ });
106
+ /**
107
+ * Education and training form schema
108
+ */
109
+ exports.EducationAndTrainingFormSchema = zod_1.z.object({
110
+ type: zod_1.z.object({
111
+ label: zod_1.z.string(),
112
+ value: zod_1.z.string(),
113
+ }),
114
+ school: zod_1.z
115
+ .string()
116
+ .min(1, "School/Instituation is required")
117
+ .max(limits_1.EDUTRAINING_INSTITUTION_MAX_LENGTH, "Institution name is too long"),
118
+ degree: zod_1.z
119
+ .string()
120
+ .min(1, "Degree is required")
121
+ .max(limits_1.EDUTRAINING_DEGREE_MAX_LENGTH, "Degree is too long"),
122
+ startDate: zod_1.z.date({
123
+ required_error: "Start date is required",
124
+ }),
125
+ endDate: zod_1.z.date().optional().nullable(),
126
+ isCurrentlyStudying: zod_1.z.boolean().or(zod_1.z.literal(false)).optional(),
127
+ });
128
+ // Helper function to check if date is in the future
129
+ const isDateInFuture = (date) => {
130
+ const today = new Date();
131
+ today.setHours(0, 0, 0, 0);
132
+ const compareDate = new Date(date);
133
+ return compareDate > today;
134
+ };
135
+ // Helper function to check if there's at least 1 month difference
136
+ const isAtLeastOneMonthDifference = (startDate, endDate) => {
137
+ const start = new Date(startDate);
138
+ const end = new Date(endDate);
139
+ // Calculate difference in months
140
+ const diffInMonths = (end.getFullYear() - start.getFullYear()) * 12 +
141
+ (end.getMonth() - start.getMonth());
142
+ return diffInMonths >= 1;
143
+ };
144
+ /**
145
+ * Work history form schema
146
+ */
147
+ exports.WorkHistoryFormSchema = zod_1.z
148
+ .object({
149
+ jobTitle: zod_1.z
150
+ .string()
151
+ .min(1, "Job title is required")
152
+ .max(limits_1.WORK_HISTORY_TITLE_MAX_LENGTH, "Job title is too long"),
153
+ organisation: zod_1.z
154
+ .string()
155
+ .min(1, "Organization is required")
156
+ .max(limits_1.WORK_HISTORY_ORGANIZATION_MAX_LENGTH, "Organization is too long"),
157
+ startDate: zod_1.z
158
+ .string()
159
+ .min(1, "Start date is required")
160
+ .refine((date) => !isDateInFuture(date), {
161
+ message: "Start date cannot be in the future",
162
+ }),
163
+ endDate: zod_1.z
164
+ .string()
165
+ .optional()
166
+ .refine((date) => !date || !isDateInFuture(date), {
167
+ message: "End date cannot be in the future",
168
+ }),
169
+ isCurrentlyWorking: zod_1.z.boolean().default(false).optional(),
170
+ })
171
+ .refine((data) => {
172
+ // Skip validation if currently working or no end date
173
+ if (data.isCurrentlyWorking || !data.endDate)
174
+ return true;
175
+ // Check if end date is after start date
176
+ const startDate = new Date(data.startDate);
177
+ const endDate = new Date(data.endDate);
178
+ return endDate > startDate;
179
+ }, {
180
+ message: "End date must be after start date",
181
+ path: ["endDate"],
182
+ })
183
+ .refine((data) => {
184
+ // Skip validation if currently working or no end date
185
+ if (data.isCurrentlyWorking || !data.endDate)
186
+ return true;
187
+ // Check if there's at least 1 month difference
188
+ return isAtLeastOneMonthDifference(data.startDate, data.endDate);
189
+ }, {
190
+ message: "There must be at least 1 month between start and end date",
191
+ path: ["endDate"],
192
+ });
@@ -1,36 +1,36 @@
1
- import { z } from "zod";
2
- export declare const HourlyRateInputZod: z.ZodObject<{
3
- service: z.ZodString;
4
- dayRates: z.ZodEffects<z.ZodArray<z.ZodObject<{
5
- day: z.ZodString;
6
- price: z.ZodNumber;
7
- }, "strip", z.ZodTypeAny, {
8
- day: string;
9
- price: number;
10
- }, {
11
- day: string;
12
- price: number;
13
- }>, "many">, {
14
- day: string;
15
- price: number;
16
- }[], {
17
- day: string;
18
- price: number;
19
- }[]>;
20
- isNegotiable: z.ZodOptional<z.ZodBoolean>;
21
- }, "strip", z.ZodTypeAny, {
22
- service: string;
23
- dayRates: {
24
- day: string;
25
- price: number;
26
- }[];
27
- isNegotiable?: boolean | undefined;
28
- }, {
29
- service: string;
30
- dayRates: {
31
- day: string;
32
- price: number;
33
- }[];
34
- isNegotiable?: boolean | undefined;
35
- }>;
36
- export type HourlyRateInputZodType = z.infer<typeof HourlyRateInputZod>;
1
+ import { z } from "zod";
2
+ export declare const HourlyRateInputZod: z.ZodObject<{
3
+ service: z.ZodString;
4
+ dayRates: z.ZodEffects<z.ZodArray<z.ZodObject<{
5
+ day: z.ZodString;
6
+ price: z.ZodNumber;
7
+ }, "strip", z.ZodTypeAny, {
8
+ day: string;
9
+ price: number;
10
+ }, {
11
+ day: string;
12
+ price: number;
13
+ }>, "many">, {
14
+ day: string;
15
+ price: number;
16
+ }[], {
17
+ day: string;
18
+ price: number;
19
+ }[]>;
20
+ isNegotiable: z.ZodOptional<z.ZodBoolean>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ service: string;
23
+ dayRates: {
24
+ day: string;
25
+ price: number;
26
+ }[];
27
+ isNegotiable?: boolean | undefined;
28
+ }, {
29
+ service: string;
30
+ dayRates: {
31
+ day: string;
32
+ price: number;
33
+ }[];
34
+ isNegotiable?: boolean | undefined;
35
+ }>;
36
+ export type HourlyRateInputZodType = z.infer<typeof HourlyRateInputZod>;
@@ -1,25 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HourlyRateInputZod = void 0;
4
- const zod_1 = require("zod");
5
- const limits_1 = require("../constants/limits");
6
- // DayRateInput validation: Check for duplicate days in the input
7
- const DayRateInputZod = zod_1.z.object({
8
- day: zod_1.z.string(),
9
- price: zod_1.z
10
- .number()
11
- .min(limits_1.MIN_HOURLY_RATE, `Hourly rate must be at least $${limits_1.MIN_HOURLY_RATE}`)
12
- .max(limits_1.MAX_HOURLY_RATE, `Hourly rate must be at most $${limits_1.MAX_HOURLY_RATE}`),
13
- });
14
- // HourlyRateInput validation: Validate dayRates for duplicates
15
- exports.HourlyRateInputZod = zod_1.z.object({
16
- service: zod_1.z.string(),
17
- dayRates: zod_1.z.array(DayRateInputZod).refine((data) => {
18
- const days = data.map((dayRate) => dayRate.day);
19
- const uniqueDays = new Set(days);
20
- return days.length === uniqueDays.size; // Ensure no duplicate days
21
- }, {
22
- message: "There should be no duplicate days in dayRates",
23
- }),
24
- isNegotiable: zod_1.z.boolean().optional(),
25
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HourlyRateInputZod = void 0;
4
+ const zod_1 = require("zod");
5
+ const limits_1 = require("../constants/limits");
6
+ // DayRateInput validation: Check for duplicate days in the input
7
+ const DayRateInputZod = zod_1.z.object({
8
+ day: zod_1.z.string(),
9
+ price: zod_1.z
10
+ .number()
11
+ .min(limits_1.MIN_HOURLY_RATE, `Hourly rate must be at least $${limits_1.MIN_HOURLY_RATE}`)
12
+ .max(limits_1.MAX_HOURLY_RATE, `Hourly rate must be at most $${limits_1.MAX_HOURLY_RATE}`),
13
+ });
14
+ // HourlyRateInput validation: Validate dayRates for duplicates
15
+ exports.HourlyRateInputZod = zod_1.z.object({
16
+ service: zod_1.z.string(),
17
+ dayRates: zod_1.z.array(DayRateInputZod).refine((data) => {
18
+ const days = data.map((dayRate) => dayRate.day);
19
+ const uniqueDays = new Set(days);
20
+ return days.length === uniqueDays.size; // Ensure no duplicate days
21
+ }, {
22
+ message: "There should be no duplicate days in dayRates",
23
+ }),
24
+ isNegotiable: zod_1.z.boolean().optional(),
25
+ });
@@ -1,6 +1,2 @@
1
- export { UserRegistrationSchema, UserRegistrationInput } from './userValiationSchema';
2
- export { EducationAndTrainingSchema, EducationAndTrainingInputValidation } from './educationSchemas';
3
- export { WorkHistorySchema, WorkHistoryInputValidation } from './workHistorySchema';
4
- export { AvailabilitiesSchemaZod, AvailabilityZodInput } from './availabilitySchemaValidation';
5
- export { HourlyRateInputZod, HourlyRateInputZodType } from './hourlyRateSchemaValidation';
6
- export { validateServices, ServicesSchema, SupportWorkerServicesSchema, validateSupportWorkerServices } from './businessServicesValidation';
1
+ export * from "./validation";
2
+ export * from "./forms";
@@ -1,18 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateSupportWorkerServices = exports.SupportWorkerServicesSchema = exports.ServicesSchema = exports.validateServices = exports.HourlyRateInputZod = exports.AvailabilitiesSchemaZod = exports.WorkHistorySchema = exports.EducationAndTrainingSchema = exports.UserRegistrationSchema = void 0;
4
- var userValiationSchema_1 = require("./userValiationSchema");
5
- Object.defineProperty(exports, "UserRegistrationSchema", { enumerable: true, get: function () { return userValiationSchema_1.UserRegistrationSchema; } });
6
- var educationSchemas_1 = require("./educationSchemas");
7
- Object.defineProperty(exports, "EducationAndTrainingSchema", { enumerable: true, get: function () { return educationSchemas_1.EducationAndTrainingSchema; } });
8
- var workHistorySchema_1 = require("./workHistorySchema");
9
- Object.defineProperty(exports, "WorkHistorySchema", { enumerable: true, get: function () { return workHistorySchema_1.WorkHistorySchema; } });
10
- var availabilitySchemaValidation_1 = require("./availabilitySchemaValidation");
11
- Object.defineProperty(exports, "AvailabilitiesSchemaZod", { enumerable: true, get: function () { return availabilitySchemaValidation_1.AvailabilitiesSchemaZod; } });
12
- var hourlyRateSchemaValidation_1 = require("./hourlyRateSchemaValidation");
13
- Object.defineProperty(exports, "HourlyRateInputZod", { enumerable: true, get: function () { return hourlyRateSchemaValidation_1.HourlyRateInputZod; } });
14
- var businessServicesValidation_1 = require("./businessServicesValidation");
15
- Object.defineProperty(exports, "validateServices", { enumerable: true, get: function () { return businessServicesValidation_1.validateServices; } });
16
- Object.defineProperty(exports, "ServicesSchema", { enumerable: true, get: function () { return businessServicesValidation_1.ServicesSchema; } });
17
- Object.defineProperty(exports, "SupportWorkerServicesSchema", { enumerable: true, get: function () { return businessServicesValidation_1.SupportWorkerServicesSchema; } });
18
- Object.defineProperty(exports, "validateSupportWorkerServices", { enumerable: true, get: function () { return businessServicesValidation_1.validateSupportWorkerServices; } });
17
+ // Core validation schemas (shared)
18
+ __exportStar(require("./validation"), exports);
19
+ // Form schemas (frontend/mobile)
20
+ __exportStar(require("./forms"), exports);
@@ -1,30 +1,30 @@
1
- import { z } from "zod";
2
- export declare const UserRegistrationSchema: z.ZodObject<{
3
- email: z.ZodEffects<z.ZodString, string, string>;
4
- username: z.ZodString;
5
- password: z.ZodString;
6
- role: z.ZodEnum<["business", "provider", "participant", "support_person", "support_worker"]>;
7
- fingerPrint: z.ZodOptional<z.ZodString>;
8
- firstName: z.ZodString;
9
- lastName: z.ZodString;
10
- isSmallProvider: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
11
- }, "strip", z.ZodTypeAny, {
12
- role: "business" | "provider" | "participant" | "support_person" | "support_worker";
13
- username: string;
14
- email: string;
15
- password: string;
16
- firstName: string;
17
- lastName: string;
18
- isSmallProvider: boolean;
19
- fingerPrint?: string | undefined;
20
- }, {
21
- role: "business" | "provider" | "participant" | "support_person" | "support_worker";
22
- username: string;
23
- email: string;
24
- password: string;
25
- firstName: string;
26
- lastName: string;
27
- fingerPrint?: string | undefined;
28
- isSmallProvider?: boolean | undefined;
29
- }>;
30
- export type UserRegistrationInput = z.infer<typeof UserRegistrationSchema>;
1
+ import { z } from "zod";
2
+ export declare const UserRegistrationSchema: z.ZodObject<{
3
+ email: z.ZodEffects<z.ZodString, string, string>;
4
+ username: z.ZodString;
5
+ password: z.ZodString;
6
+ role: z.ZodEnum<["business", "provider", "participant", "support_person", "support_worker"]>;
7
+ fingerPrint: z.ZodOptional<z.ZodString>;
8
+ firstName: z.ZodString;
9
+ lastName: z.ZodString;
10
+ isSmallProvider: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ role: "business" | "provider" | "participant" | "support_person" | "support_worker";
13
+ username: string;
14
+ email: string;
15
+ password: string;
16
+ firstName: string;
17
+ lastName: string;
18
+ isSmallProvider: boolean;
19
+ fingerPrint?: string | undefined;
20
+ }, {
21
+ role: "business" | "provider" | "participant" | "support_person" | "support_worker";
22
+ username: string;
23
+ email: string;
24
+ password: string;
25
+ firstName: string;
26
+ lastName: string;
27
+ fingerPrint?: string | undefined;
28
+ isSmallProvider?: boolean | undefined;
29
+ }>;
30
+ export type UserRegistrationInput = z.infer<typeof UserRegistrationSchema>;
@@ -1,38 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserRegistrationSchema = void 0;
4
- const zod_1 = require("zod");
5
- const limits_1 = require("../constants/limits");
6
- exports.UserRegistrationSchema = zod_1.z.object({
7
- email: zod_1.z
8
- .string()
9
- .email()
10
- .max(limits_1.EMAIL_MAX_LENGTH, `Email must be at most ${limits_1.EMAIL_MAX_LENGTH} characters long`)
11
- .refine((email) => !email.includes("+"), {
12
- message: "Email aliasing with '+' is not allowed",
13
- }),
14
- username: zod_1.z
15
- .string()
16
- .min(limits_1.USERNAME_MIN_LENGTH, `Username must be at least ${limits_1.USERNAME_MIN_LENGTH} characters long`)
17
- .max(limits_1.USERNAME_MAX_LENGTH, `Username must be at most ${limits_1.USERNAME_MAX_LENGTH} characters long`),
18
- password: zod_1.z
19
- .string()
20
- .min(limits_1.PASSWORD_MIN_LENGTH, `Password must be at least ${limits_1.PASSWORD_MIN_LENGTH} characters long`)
21
- .max(limits_1.PASSWORD_MAX_LENGTH, `Password must be at most ${limits_1.PASSWORD_MAX_LENGTH} characters long`),
22
- role: zod_1.z.enum(["business", "provider", "participant", "support_person", "support_worker"], {
23
- message: "Role must be one of: business, provider, participant, support_person, support_worker",
24
- }),
25
- fingerPrint: zod_1.z.string().optional(),
26
- firstName: zod_1.z
27
- .string()
28
- .min(limits_1.NAME_MIN_LENGTH, `First name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
29
- .max(limits_1.NAME_MAX_LENGTH, `First name must be at most ${limits_1.NAME_MAX_LENGTH} characters long`),
30
- lastName: zod_1.z
31
- .string()
32
- .min(limits_1.NAME_MIN_LENGTH, `Last name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
33
- .max(limits_1.NAME_MAX_LENGTH, `Last name must be at most ${limits_1.NAME_MAX_LENGTH} characters long`),
34
- isSmallProvider: zod_1.z.boolean().optional().default(false),
35
- // businessName: z.string().optional(),
36
- // entityTypeCode: z.string().optional(),
37
- // abn: z.string().optional(),
38
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserRegistrationSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const limits_1 = require("../constants/limits");
6
+ exports.UserRegistrationSchema = zod_1.z.object({
7
+ email: zod_1.z
8
+ .string()
9
+ .email()
10
+ .max(limits_1.EMAIL_MAX_LENGTH, `Email must be at most ${limits_1.EMAIL_MAX_LENGTH} characters long`)
11
+ .refine((email) => !email.includes("+"), {
12
+ message: "Email aliasing with '+' is not allowed",
13
+ }),
14
+ username: zod_1.z
15
+ .string()
16
+ .min(limits_1.USERNAME_MIN_LENGTH, `Username must be at least ${limits_1.USERNAME_MIN_LENGTH} characters long`)
17
+ .max(limits_1.USERNAME_MAX_LENGTH, `Username must be at most ${limits_1.USERNAME_MAX_LENGTH} characters long`),
18
+ password: zod_1.z
19
+ .string()
20
+ .min(limits_1.PASSWORD_MIN_LENGTH, `Password must be at least ${limits_1.PASSWORD_MIN_LENGTH} characters long`)
21
+ .max(limits_1.PASSWORD_MAX_LENGTH, `Password must be at most ${limits_1.PASSWORD_MAX_LENGTH} characters long`),
22
+ role: zod_1.z.enum(["business", "provider", "participant", "support_person", "support_worker"], {
23
+ message: "Role must be one of: business, provider, participant, support_person, support_worker",
24
+ }),
25
+ fingerPrint: zod_1.z.string().optional(),
26
+ firstName: zod_1.z
27
+ .string()
28
+ .min(limits_1.NAME_MIN_LENGTH, `First name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
29
+ .max(limits_1.NAME_MAX_LENGTH, `First name must be at most ${limits_1.NAME_MAX_LENGTH} characters long`),
30
+ lastName: zod_1.z
31
+ .string()
32
+ .min(limits_1.NAME_MIN_LENGTH, `Last name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
33
+ .max(limits_1.NAME_MAX_LENGTH, `Last name must be at most ${limits_1.NAME_MAX_LENGTH} characters long`),
34
+ isSmallProvider: zod_1.z.boolean().optional().default(false),
35
+ // businessName: z.string().optional(),
36
+ // entityTypeCode: z.string().optional(),
37
+ // abn: z.string().optional(),
38
+ });
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Reusable email validation schema
4
+ */
5
+ export declare const emailSchema: z.ZodString;
6
+ /**
7
+ * Reusable password validation schema
8
+ */
9
+ export declare const passwordSchema: z.ZodString;
10
+ /**
11
+ * Reusable password change schema
12
+ */
13
+ export declare const passwordChangeSchema: z.ZodEffects<z.ZodObject<{
14
+ currentPassword: z.ZodString;
15
+ newPassword: z.ZodString;
16
+ confirmPassword: z.ZodString;
17
+ }, "strip", z.ZodTypeAny, {
18
+ currentPassword: string;
19
+ newPassword: string;
20
+ confirmPassword: string;
21
+ }, {
22
+ currentPassword: string;
23
+ newPassword: string;
24
+ confirmPassword: string;
25
+ }>, {
26
+ currentPassword: string;
27
+ newPassword: string;
28
+ confirmPassword: string;
29
+ }, {
30
+ currentPassword: string;
31
+ newPassword: string;
32
+ confirmPassword: string;
33
+ }>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.passwordChangeSchema = exports.passwordSchema = exports.emailSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const limits_1 = require("../constants/limits");
6
+ /**
7
+ * Reusable email validation schema
8
+ */
9
+ exports.emailSchema = zod_1.z
10
+ .string()
11
+ .min(1, "Email is required")
12
+ .max(limits_1.EMAIL_MAX_LENGTH, "Email is too long")
13
+ .email("Invalid email")
14
+ .regex(/^[^+]+@/, "Email aliasing is not allowed");
15
+ /**
16
+ * Reusable password validation schema
17
+ */
18
+ exports.passwordSchema = zod_1.z
19
+ .string()
20
+ .min(1, "Password is required")
21
+ .min(limits_1.PASSWORD_MIN_LENGTH, `Password must be at least ${limits_1.PASSWORD_MIN_LENGTH} characters long`)
22
+ .max(limits_1.PASSWORD_MAX_LENGTH, `Password must be at most ${limits_1.PASSWORD_MAX_LENGTH} characters long`);
23
+ /**
24
+ * Reusable password change schema
25
+ */
26
+ exports.passwordChangeSchema = zod_1.z
27
+ .object({
28
+ currentPassword: zod_1.z.string().min(1, "Current password is required"),
29
+ newPassword: exports.passwordSchema,
30
+ confirmPassword: zod_1.z
31
+ .string()
32
+ .min(1, "Confirm password is required")
33
+ .max(limits_1.PASSWORD_MAX_LENGTH, "Confirm password is too long"),
34
+ })
35
+ .refine((data) => data.newPassword === data.confirmPassword, {
36
+ message: "Passwords don't match",
37
+ path: ["confirmPassword"],
38
+ });
@@ -1,33 +1,33 @@
1
- import { z } from "zod";
2
- export declare const WorkHistorySchema: z.ZodEffects<z.ZodObject<{
3
- jobTitle: z.ZodString;
4
- startDate: z.ZodDate;
5
- endDate: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
6
- organisation: z.ZodString;
7
- isCurrentlyWorking: z.ZodDefault<z.ZodBoolean>;
8
- }, "strip", z.ZodTypeAny, {
9
- startDate: Date;
10
- jobTitle: string;
11
- organisation: string;
12
- isCurrentlyWorking: boolean;
13
- endDate?: Date | null | undefined;
14
- }, {
15
- startDate: Date;
16
- jobTitle: string;
17
- organisation: string;
18
- endDate?: Date | null | undefined;
19
- isCurrentlyWorking?: boolean | undefined;
20
- }>, {
21
- startDate: Date;
22
- jobTitle: string;
23
- organisation: string;
24
- isCurrentlyWorking: boolean;
25
- endDate?: Date | null | undefined;
26
- }, {
27
- startDate: Date;
28
- jobTitle: string;
29
- organisation: string;
30
- endDate?: Date | null | undefined;
31
- isCurrentlyWorking?: boolean | undefined;
32
- }>;
33
- export type WorkHistoryInputValidation = z.infer<typeof WorkHistorySchema>;
1
+ import { z } from "zod";
2
+ export declare const WorkHistorySchema: z.ZodEffects<z.ZodObject<{
3
+ jobTitle: z.ZodString;
4
+ startDate: z.ZodDate;
5
+ endDate: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
6
+ organisation: z.ZodString;
7
+ isCurrentlyWorking: z.ZodDefault<z.ZodBoolean>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ startDate: Date;
10
+ jobTitle: string;
11
+ organisation: string;
12
+ isCurrentlyWorking: boolean;
13
+ endDate?: Date | null | undefined;
14
+ }, {
15
+ startDate: Date;
16
+ jobTitle: string;
17
+ organisation: string;
18
+ endDate?: Date | null | undefined;
19
+ isCurrentlyWorking?: boolean | undefined;
20
+ }>, {
21
+ startDate: Date;
22
+ jobTitle: string;
23
+ organisation: string;
24
+ isCurrentlyWorking: boolean;
25
+ endDate?: Date | null | undefined;
26
+ }, {
27
+ startDate: Date;
28
+ jobTitle: string;
29
+ organisation: string;
30
+ endDate?: Date | null | undefined;
31
+ isCurrentlyWorking?: boolean | undefined;
32
+ }>;
33
+ export type WorkHistoryInputValidation = z.infer<typeof WorkHistorySchema>;