@zyacreatives/shared 1.4.8 → 1.5.0

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.
@@ -6,3 +6,4 @@ export * from "./project";
6
6
  export * from "./investor";
7
7
  export * from "./discipline";
8
8
  export * from "./file";
9
+ export * from "./username";
@@ -22,3 +22,4 @@ __exportStar(require("./project"), exports);
22
22
  __exportStar(require("./investor"), exports);
23
23
  __exportStar(require("./discipline"), exports);
24
24
  __exportStar(require("./file"), exports);
25
+ __exportStar(require("./username"), exports);
@@ -258,6 +258,33 @@ exports.CreateProjectInputSchema = zod_openapi_1.z
258
258
  description: "Array of files/images for the project.",
259
259
  example: [],
260
260
  }),
261
+ })
262
+ .superRefine(({ startDate, endDate }, ctx) => {
263
+ const today = new Date();
264
+ today.setHours(0, 0, 0, 0);
265
+ if (startDate > today) {
266
+ ctx.addIssue({
267
+ path: ["startDate"],
268
+ code: "custom",
269
+ message: "Start date cannot be in the future",
270
+ });
271
+ }
272
+ if (endDate) {
273
+ if (endDate > today) {
274
+ ctx.addIssue({
275
+ path: ["endDate"],
276
+ code: "custom",
277
+ message: "End date cannot be in the future",
278
+ });
279
+ }
280
+ if (startDate > endDate) {
281
+ ctx.addIssue({
282
+ path: ["startDate"],
283
+ code: "custom",
284
+ message: "Start date cannot be after end date",
285
+ });
286
+ }
287
+ }
261
288
  })
262
289
  .openapi({
263
290
  title: "Create Project",
@@ -1 +1,4 @@
1
- export {};
1
+ import { z } from "@hono/zod-openapi";
2
+ export declare const UsernameSchema: z.ZodObject<{
3
+ username: z.ZodString;
4
+ }, z.core.$strip>;
@@ -1,2 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UsernameSchema = void 0;
4
+ const zod_openapi_1 = require("@hono/zod-openapi");
5
+ exports.UsernameSchema = zod_openapi_1.z.object({
6
+ username: zod_openapi_1.z
7
+ .string()
8
+ .max(32, { message: "Username must be at most 32 characters" })
9
+ .regex(/^[a-zA-Z0-9_]+$/, {
10
+ message: "Username may only contain letters, numbers, and underscores",
11
+ }),
12
+ });
@@ -6,3 +6,4 @@ export * from "./file";
6
6
  export * from "./investor";
7
7
  export * from "./project";
8
8
  export * from "./user";
9
+ export * from "./username";
@@ -22,3 +22,4 @@ __exportStar(require("./file"), exports);
22
22
  __exportStar(require("./investor"), exports);
23
23
  __exportStar(require("./project"), exports);
24
24
  __exportStar(require("./user"), exports);
25
+ __exportStar(require("./username"), exports);
@@ -0,0 +1,3 @@
1
+ import { z } from "@hono/zod-openapi";
2
+ import { UsernameSchema } from "../schemas";
3
+ export type UsernameInput = z.infer<typeof UsernameSchema>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyacreatives/shared",
3
- "version": "1.4.8",
3
+ "version": "1.5.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -6,3 +6,4 @@ export * from "./project";
6
6
  export * from "./investor";
7
7
  export * from "./discipline";
8
8
  export * from "./file";
9
+ export * from "./username";
@@ -1,6 +1,7 @@
1
1
  import { z } from "@hono/zod-openapi";
2
2
  import { CLIENT_TYPES, ROLES } from "../constants";
3
3
  import { CreateFileInputSchema, FileEntitySchema } from "./file";
4
+
4
5
  export const ProjectEntitySchema = z
5
6
  .object({
6
7
  description: z.string().optional().openapi({
@@ -271,6 +272,34 @@ export const CreateProjectInputSchema = z
271
272
  example: [],
272
273
  }),
273
274
  })
275
+ .superRefine(({ startDate, endDate }, ctx) => {
276
+ const today = new Date();
277
+ today.setHours(0, 0, 0, 0);
278
+ if (startDate > today) {
279
+ ctx.addIssue({
280
+ path: ["startDate"],
281
+ code: "custom",
282
+ message: "Start date cannot be in the future",
283
+ });
284
+ }
285
+ if (endDate) {
286
+ if (endDate > today) {
287
+ ctx.addIssue({
288
+ path: ["endDate"],
289
+ code: "custom",
290
+ message: "End date cannot be in the future",
291
+ });
292
+ }
293
+
294
+ if (startDate > endDate) {
295
+ ctx.addIssue({
296
+ path: ["startDate"],
297
+ code: "custom",
298
+ message: "Start date cannot be after end date",
299
+ });
300
+ }
301
+ }
302
+ })
274
303
  .openapi({
275
304
  title: "Create Project",
276
305
  description: "Schema for creating a new project.",
@@ -0,0 +1,10 @@
1
+ import { z } from "@hono/zod-openapi";
2
+
3
+ export const UsernameSchema = z.object({
4
+ username: z
5
+ .string()
6
+ .max(32, { message: "Username must be at most 32 characters" })
7
+ .regex(/^[a-zA-Z0-9_]+$/, {
8
+ message: "Username may only contain letters, numbers, and underscores",
9
+ }),
10
+ });
@@ -6,3 +6,4 @@ export * from "./file";
6
6
  export * from "./investor";
7
7
  export * from "./project";
8
8
  export * from "./user";
9
+ export * from "./username";
@@ -0,0 +1,4 @@
1
+ import { z } from "@hono/zod-openapi";
2
+ import { UsernameSchema } from "../schemas";
3
+
4
+ export type UsernameInput = z.infer<typeof UsernameSchema>;