@timothyw/pat-common 1.0.57 → 1.0.58

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.
@@ -2,10 +2,12 @@ import { z } from "zod";
2
2
  import { Habit, HabitEntryStatus } from "../../models";
3
3
  import { DateOnlyString } from "../../misc-types";
4
4
  export declare const createHabitEntryRequestSchema: z.ZodObject<{
5
- date: z.ZodEffects<z.ZodString, string, string>;
5
+ date: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, DateOnlyString, string>;
6
6
  status: z.ZodNativeEnum<typeof HabitEntryStatus>;
7
7
  }, "strip", z.ZodTypeAny, {
8
- date: string;
8
+ date: string & {
9
+ readonly __brand: "DateOnlyString";
10
+ };
9
11
  status: HabitEntryStatus;
10
12
  }, {
11
13
  date: string;
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  export type DateOnlyString = string & {
3
3
  readonly __brand: "DateOnlyString";
4
4
  };
5
- export declare const dateOnlyStringSchema: z.ZodEffects<z.ZodString, string, string>;
5
+ export declare const dateOnlyStringSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, DateOnlyString, string>;
6
6
  export type DateString = string & {
7
7
  readonly __brand: "DateString";
8
8
  };
@@ -5,7 +5,8 @@ const zod_1 = require("zod");
5
5
  exports.dateOnlyStringSchema = zod_1.z.string()
6
6
  .refine(val => /^\d{4}-\d{2}-\d{2}$/.test(val), {
7
7
  message: "Invalid date-only string format, expected YYYY-MM-DD",
8
- });
8
+ })
9
+ .transform(val => val);
9
10
  exports.dateStringSchema = zod_1.z.string()
10
11
  .refine(val => !isNaN(Date.parse(val)), {
11
12
  message: "Invalid date string",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@timothyw/pat-common",
3
3
  "description": "",
4
4
  "author": "Timothy Washburn",
5
- "version": "1.0.57",
5
+ "version": "1.0.58",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
@@ -5,7 +5,8 @@ export type DateOnlyString = string & { readonly __brand: "DateOnlyString" };
5
5
  export const dateOnlyStringSchema = z.string()
6
6
  .refine(val => /^\d{4}-\d{2}-\d{2}$/.test(val), {
7
7
  message: "Invalid date-only string format, expected YYYY-MM-DD",
8
- });
8
+ })
9
+ .transform(val => val as DateOnlyString);
9
10
 
10
11
  export type DateString = string & { readonly __brand: "DateString" };
11
12