zod-joda 1.1.3 → 2.0.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.
- package/LICENSE +1 -1
- package/README.md +20 -10
- package/dist/core.d.ts +19 -0
- package/dist/core.js +36 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +42 -0
- package/dist/mini.d.ts +15 -0
- package/dist/mini.js +42 -0
- package/package.json +54 -51
- package/lib/ZodJodaLocalDate.d.ts +0 -7
- package/lib/ZodJodaLocalDate.js +0 -19
- package/lib/ZodJodaLocalDate.js.map +0 -1
- package/lib/ZodJodaLocalDateTime.d.ts +0 -7
- package/lib/ZodJodaLocalDateTime.js +0 -19
- package/lib/ZodJodaLocalDateTime.js.map +0 -1
- package/lib/ZodJodaLocalTime.d.ts +0 -7
- package/lib/ZodJodaLocalTime.js +0 -19
- package/lib/ZodJodaLocalTime.js.map +0 -1
- package/lib/ZodJodaZonedDateTime.d.ts +0 -7
- package/lib/ZodJodaZonedDateTime.js +0 -19
- package/lib/ZodJodaZonedDateTime.js.map +0 -1
- package/lib/index.d.ts +0 -29
- package/lib/index.js +0 -17
- package/lib/index.js.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
# JS-Joda integration for Zod validation library
|
|
2
2
|
|
|
3
|
-
[](https://github.com/dasprid/zod-joda/actions/workflows/release.yml)
|
|
4
4
|
[](https://codecov.io/gh/DASPRiD/zod-joda)
|
|
5
5
|
|
|
6
|
-
This library adds additional types
|
|
7
|
-
|
|
6
|
+
This library adds additional types for [Zod](https://github.com/colinhacks/zod/) to parse and validate dates, times and durations as
|
|
7
|
+
[js-joda](https://github.com/js-joda/js-joda) types. This library has support for both `zod` and `@zod/mini`.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```bash
|
|
12
|
+
npm install zod-joda @js-joda/core
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Additionally, you should have both zod and js-joda installed:
|
|
14
|
+
# a) Install zod peer dependency for full zod support
|
|
15
|
+
npm install zod
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
# b) Install zod mini for size optimized results
|
|
18
|
+
npm install @zod/mini
|
|
19
|
+
```
|
|
18
20
|
|
|
19
21
|
## Quick Start
|
|
20
22
|
|
|
@@ -25,12 +27,20 @@ method:
|
|
|
25
27
|
import {zj} from 'zod-joda';
|
|
26
28
|
```
|
|
27
29
|
|
|
30
|
+
For `@zod/mini`, import from the mini sub-path:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import {zj} from 'zod-joda/mini';
|
|
34
|
+
```
|
|
35
|
+
|
|
28
36
|
This library supplies the following types:
|
|
29
37
|
|
|
38
|
+
- `zj.duration()`
|
|
30
39
|
- `zj.localDate()`
|
|
31
40
|
- `zj.localDateTime()`
|
|
32
41
|
- `zj.localTime()`
|
|
33
42
|
- `zj.zonedDateTime()`
|
|
34
43
|
|
|
35
|
-
All constructors take an optional object with a `dateTimeFormatter` property, which allows you to
|
|
36
|
-
behavior of how dates and times will be parsed. By default, every value should be in an ISO 8601
|
|
44
|
+
All constructors except `duration` take an optional object with a `dateTimeFormatter` property, which allows you to
|
|
45
|
+
change the default behavior of how dates and times will be parsed. By default, every value should be in an ISO 8601
|
|
46
|
+
format.
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DateTimeFormatter, Duration, LocalDate, LocalDateTime, LocalTime, ZonedDateTime } from "@js-joda/core";
|
|
2
|
+
export type CoreParams = {
|
|
3
|
+
error?: string;
|
|
4
|
+
};
|
|
5
|
+
export type TransformConstructorConfig<T, P extends CoreParams> = {
|
|
6
|
+
isInstance: (input: unknown) => input is T;
|
|
7
|
+
parse: (input: string, params?: P) => T;
|
|
8
|
+
invalidMessage: string;
|
|
9
|
+
schemaFormat: string;
|
|
10
|
+
example: (params?: P) => string;
|
|
11
|
+
};
|
|
12
|
+
export type TemporalParams = CoreParams & {
|
|
13
|
+
dateTimeFormatter?: DateTimeFormatter;
|
|
14
|
+
};
|
|
15
|
+
export declare const durationConfig: TransformConstructorConfig<Duration, CoreParams>;
|
|
16
|
+
export declare const localDateConfig: TransformConstructorConfig<LocalDate, TemporalParams>;
|
|
17
|
+
export declare const localDateTimeConfig: TransformConstructorConfig<LocalDateTime, TemporalParams>;
|
|
18
|
+
export declare const localTimeConfig: TransformConstructorConfig<LocalTime, TemporalParams>;
|
|
19
|
+
export declare const zonedDateTimeConfig: TransformConstructorConfig<ZonedDateTime, TemporalParams>;
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DateTimeFormatter, Duration, LocalDate, LocalDateTime, LocalTime, ZoneId, ZonedDateTime, } from "@js-joda/core";
|
|
2
|
+
export const durationConfig = {
|
|
3
|
+
isInstance: (input) => input instanceof Duration,
|
|
4
|
+
parse: (input) => Duration.parse(input),
|
|
5
|
+
invalidMessage: "Invalid duration",
|
|
6
|
+
schemaFormat: "duration",
|
|
7
|
+
example: () => "PT1H",
|
|
8
|
+
};
|
|
9
|
+
export const localDateConfig = {
|
|
10
|
+
isInstance: (input) => input instanceof LocalDate,
|
|
11
|
+
parse: (input, params) => LocalDate.parse(input, params?.dateTimeFormatter),
|
|
12
|
+
invalidMessage: "Invalid local date",
|
|
13
|
+
schemaFormat: "date",
|
|
14
|
+
example: (params) => LocalDate.of(2020, 1, 1).format(params?.dateTimeFormatter ?? DateTimeFormatter.ISO_LOCAL_DATE),
|
|
15
|
+
};
|
|
16
|
+
export const localDateTimeConfig = {
|
|
17
|
+
isInstance: (input) => input instanceof LocalDateTime,
|
|
18
|
+
parse: (input, params) => LocalDateTime.parse(input, params?.dateTimeFormatter),
|
|
19
|
+
invalidMessage: "Invalid local date time",
|
|
20
|
+
schemaFormat: "local-date-time",
|
|
21
|
+
example: (params) => LocalDateTime.of(2020, 1, 1, 14, 0, 0, 0).format(params?.dateTimeFormatter ?? DateTimeFormatter.ISO_LOCAL_DATE_TIME),
|
|
22
|
+
};
|
|
23
|
+
export const localTimeConfig = {
|
|
24
|
+
isInstance: (input) => input instanceof LocalTime,
|
|
25
|
+
parse: (input, params) => LocalTime.parse(input, params?.dateTimeFormatter),
|
|
26
|
+
invalidMessage: "Invalid local time",
|
|
27
|
+
schemaFormat: "time",
|
|
28
|
+
example: (params) => LocalTime.of(14, 0, 0, 0).format(params?.dateTimeFormatter ?? DateTimeFormatter.ISO_LOCAL_TIME),
|
|
29
|
+
};
|
|
30
|
+
export const zonedDateTimeConfig = {
|
|
31
|
+
isInstance: (input) => input instanceof ZonedDateTime,
|
|
32
|
+
parse: (input, params) => ZonedDateTime.parse(input, params?.dateTimeFormatter),
|
|
33
|
+
invalidMessage: "Invalid zoned date time",
|
|
34
|
+
schemaFormat: "date-time",
|
|
35
|
+
example: (params) => ZonedDateTime.of(2020, 1, 1, 14, 0, 0, 0, ZoneId.UTC).format(params?.dateTimeFormatter ?? DateTimeFormatter.ISO_OFFSET_DATE_TIME),
|
|
36
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ZodType } from "zod/v4";
|
|
2
|
+
import { type CoreParams } from "./core.js";
|
|
3
|
+
export declare const duration: (params?: CoreParams | undefined) => ZodType<import("@js-joda/core").Duration, string | import("@js-joda/core").Duration, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").Duration, string | import("@js-joda/core").Duration>>;
|
|
4
|
+
export declare const localDate: (params?: import("./core.js").TemporalParams | undefined) => ZodType<import("@js-joda/core").LocalDate, string | import("@js-joda/core").LocalDate, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalDate, string | import("@js-joda/core").LocalDate>>;
|
|
5
|
+
export declare const localDateTime: (params?: import("./core.js").TemporalParams | undefined) => ZodType<import("@js-joda/core").LocalDateTime, string | import("@js-joda/core").LocalDateTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalDateTime, string | import("@js-joda/core").LocalDateTime>>;
|
|
6
|
+
export declare const localTime: (params?: import("./core.js").TemporalParams | undefined) => ZodType<import("@js-joda/core").LocalTime, string | import("@js-joda/core").LocalTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalTime, string | import("@js-joda/core").LocalTime>>;
|
|
7
|
+
export declare const zonedDateTime: (params?: import("./core.js").TemporalParams | undefined) => ZodType<import("@js-joda/core").ZonedDateTime, string | import("@js-joda/core").ZonedDateTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").ZonedDateTime, string | import("@js-joda/core").ZonedDateTime>>;
|
|
8
|
+
export declare const zj: {
|
|
9
|
+
duration: (params?: CoreParams | undefined) => ZodType<import("@js-joda/core").Duration, string | import("@js-joda/core").Duration, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").Duration, string | import("@js-joda/core").Duration>>;
|
|
10
|
+
localDate: (params?: import("./core.js").TemporalParams | undefined) => ZodType<import("@js-joda/core").LocalDate, string | import("@js-joda/core").LocalDate, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalDate, string | import("@js-joda/core").LocalDate>>;
|
|
11
|
+
localDateTime: (params?: import("./core.js").TemporalParams | undefined) => ZodType<import("@js-joda/core").LocalDateTime, string | import("@js-joda/core").LocalDateTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalDateTime, string | import("@js-joda/core").LocalDateTime>>;
|
|
12
|
+
localTime: (params?: import("./core.js").TemporalParams | undefined) => ZodType<import("@js-joda/core").LocalTime, string | import("@js-joda/core").LocalTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalTime, string | import("@js-joda/core").LocalTime>>;
|
|
13
|
+
zonedDateTime: (params?: import("./core.js").TemporalParams | undefined) => ZodType<import("@js-joda/core").ZonedDateTime, string | import("@js-joda/core").ZonedDateTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").ZonedDateTime, string | import("@js-joda/core").ZonedDateTime>>;
|
|
14
|
+
};
|
|
15
|
+
export default zj;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { transform } from "zod/v4";
|
|
2
|
+
import { durationConfig, localDateConfig, localDateTimeConfig, localTimeConfig, zonedDateTimeConfig, } from "./core.js";
|
|
3
|
+
const createParseConstructor = ({ isInstance, parse, invalidMessage, schemaFormat, example, }) => (params) => {
|
|
4
|
+
const instance = transform((input, context) => {
|
|
5
|
+
if (isInstance(input)) {
|
|
6
|
+
return input;
|
|
7
|
+
}
|
|
8
|
+
if (typeof input === "string") {
|
|
9
|
+
try {
|
|
10
|
+
return parse(input, params);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
// Noop
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
context.issues.push({
|
|
17
|
+
code: "custom",
|
|
18
|
+
message: params?.error ?? invalidMessage,
|
|
19
|
+
input: context.value,
|
|
20
|
+
});
|
|
21
|
+
return undefined;
|
|
22
|
+
});
|
|
23
|
+
instance._zod.toJSONSchema = () => ({
|
|
24
|
+
type: "string",
|
|
25
|
+
format: schemaFormat,
|
|
26
|
+
example: example(params),
|
|
27
|
+
});
|
|
28
|
+
return instance;
|
|
29
|
+
};
|
|
30
|
+
export const duration = createParseConstructor(durationConfig);
|
|
31
|
+
export const localDate = createParseConstructor(localDateConfig);
|
|
32
|
+
export const localDateTime = createParseConstructor(localDateTimeConfig);
|
|
33
|
+
export const localTime = createParseConstructor(localTimeConfig);
|
|
34
|
+
export const zonedDateTime = createParseConstructor(zonedDateTimeConfig);
|
|
35
|
+
export const zj = {
|
|
36
|
+
duration,
|
|
37
|
+
localDate,
|
|
38
|
+
localDateTime,
|
|
39
|
+
localTime,
|
|
40
|
+
zonedDateTime,
|
|
41
|
+
};
|
|
42
|
+
export default zj;
|
package/dist/mini.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ZodMiniType } from "zod/v4/mini";
|
|
2
|
+
import { type CoreParams } from "./core.js";
|
|
3
|
+
export declare const duration: (params?: CoreParams | undefined) => ZodMiniType<import("@js-joda/core").Duration, string | import("@js-joda/core").Duration, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").Duration, string | import("@js-joda/core").Duration>>;
|
|
4
|
+
export declare const localDate: (params?: import("./core.js").TemporalParams | undefined) => ZodMiniType<import("@js-joda/core").LocalDate, string | import("@js-joda/core").LocalDate, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalDate, string | import("@js-joda/core").LocalDate>>;
|
|
5
|
+
export declare const localDateTime: (params?: import("./core.js").TemporalParams | undefined) => ZodMiniType<import("@js-joda/core").LocalDateTime, string | import("@js-joda/core").LocalDateTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalDateTime, string | import("@js-joda/core").LocalDateTime>>;
|
|
6
|
+
export declare const localTime: (params?: import("./core.js").TemporalParams | undefined) => ZodMiniType<import("@js-joda/core").LocalTime, string | import("@js-joda/core").LocalTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalTime, string | import("@js-joda/core").LocalTime>>;
|
|
7
|
+
export declare const zonedDateTime: (params?: import("./core.js").TemporalParams | undefined) => ZodMiniType<import("@js-joda/core").ZonedDateTime, string | import("@js-joda/core").ZonedDateTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").ZonedDateTime, string | import("@js-joda/core").ZonedDateTime>>;
|
|
8
|
+
export declare const zj: {
|
|
9
|
+
duration: (params?: CoreParams | undefined) => ZodMiniType<import("@js-joda/core").Duration, string | import("@js-joda/core").Duration, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").Duration, string | import("@js-joda/core").Duration>>;
|
|
10
|
+
localDate: (params?: import("./core.js").TemporalParams | undefined) => ZodMiniType<import("@js-joda/core").LocalDate, string | import("@js-joda/core").LocalDate, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalDate, string | import("@js-joda/core").LocalDate>>;
|
|
11
|
+
localDateTime: (params?: import("./core.js").TemporalParams | undefined) => ZodMiniType<import("@js-joda/core").LocalDateTime, string | import("@js-joda/core").LocalDateTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalDateTime, string | import("@js-joda/core").LocalDateTime>>;
|
|
12
|
+
localTime: (params?: import("./core.js").TemporalParams | undefined) => ZodMiniType<import("@js-joda/core").LocalTime, string | import("@js-joda/core").LocalTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").LocalTime, string | import("@js-joda/core").LocalTime>>;
|
|
13
|
+
zonedDateTime: (params?: import("./core.js").TemporalParams | undefined) => ZodMiniType<import("@js-joda/core").ZonedDateTime, string | import("@js-joda/core").ZonedDateTime, import("zod/v4/core").$ZodTypeInternals<import("@js-joda/core").ZonedDateTime, string | import("@js-joda/core").ZonedDateTime>>;
|
|
14
|
+
};
|
|
15
|
+
export default zj;
|
package/dist/mini.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { transform } from "zod/v4/mini";
|
|
2
|
+
import { durationConfig, localDateConfig, localDateTimeConfig, localTimeConfig, zonedDateTimeConfig, } from "./core.js";
|
|
3
|
+
const createParseConstructor = ({ isInstance, parse, invalidMessage, schemaFormat, example, }) => (params) => {
|
|
4
|
+
const instance = transform((input, context) => {
|
|
5
|
+
if (isInstance(input)) {
|
|
6
|
+
return input;
|
|
7
|
+
}
|
|
8
|
+
if (typeof input === "string") {
|
|
9
|
+
try {
|
|
10
|
+
return parse(input, params);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
// Noop
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
context.issues.push({
|
|
17
|
+
code: "custom",
|
|
18
|
+
message: params?.error ?? invalidMessage,
|
|
19
|
+
input: context.value,
|
|
20
|
+
});
|
|
21
|
+
return undefined;
|
|
22
|
+
});
|
|
23
|
+
instance._zod.toJSONSchema = () => ({
|
|
24
|
+
type: "string",
|
|
25
|
+
format: schemaFormat,
|
|
26
|
+
example: example(params),
|
|
27
|
+
});
|
|
28
|
+
return instance;
|
|
29
|
+
};
|
|
30
|
+
export const duration = createParseConstructor(durationConfig);
|
|
31
|
+
export const localDate = createParseConstructor(localDateConfig);
|
|
32
|
+
export const localDateTime = createParseConstructor(localDateTimeConfig);
|
|
33
|
+
export const localTime = createParseConstructor(localTimeConfig);
|
|
34
|
+
export const zonedDateTime = createParseConstructor(zonedDateTimeConfig);
|
|
35
|
+
export const zj = {
|
|
36
|
+
duration,
|
|
37
|
+
localDate,
|
|
38
|
+
localDateTime,
|
|
39
|
+
localTime,
|
|
40
|
+
zonedDateTime,
|
|
41
|
+
};
|
|
42
|
+
export default zj;
|
package/package.json
CHANGED
|
@@ -1,34 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod-joda",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "JS-Joda integration for Zod validation library",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"types": "lib/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com:dasprid/zod-joda.git"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"lib/**/*"
|
|
13
|
-
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"test": "mocha -r ts-node/register test/**/*.ts",
|
|
16
|
-
"coverage": "nyc npm test",
|
|
17
|
-
"test-ci": "nyc --reporter=lcov npm test",
|
|
18
|
-
"build": "rimraf ./build && tsc",
|
|
19
|
-
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
|
20
|
-
"lint:fix": "npm run lint -- --fix",
|
|
21
|
-
"_postinstall": "is-ci || husky install",
|
|
22
|
-
"prepublishOnly": "npm test && npm run lint && pinst --disable",
|
|
23
|
-
"postpublish": "pinst --enable",
|
|
24
|
-
"prepare": "npm run build",
|
|
25
|
-
"preversion": "npm run lint",
|
|
26
|
-
"version": "npm run lint:fix && git add -A src",
|
|
27
|
-
"postversion": "git push && git push --tags"
|
|
28
|
-
},
|
|
29
|
-
"lint-staged": {
|
|
30
|
-
"*.{js,jsx,ts,tsx}": "eslint --cache --fix"
|
|
31
|
-
},
|
|
32
5
|
"author": "Ben Scholzen 'DASPRiD'",
|
|
33
6
|
"keywords": [
|
|
34
7
|
"Zod",
|
|
@@ -38,32 +11,62 @@
|
|
|
38
11
|
"TypeScript"
|
|
39
12
|
],
|
|
40
13
|
"license": "BSD-2-Clause",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/dasprid/zod-joda.git"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/**/*"
|
|
22
|
+
],
|
|
23
|
+
"module": "dist/index.js",
|
|
24
|
+
"types": "dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"./mini": {
|
|
33
|
+
"import": {
|
|
34
|
+
"types": "./dist/mini.d.ts",
|
|
35
|
+
"default": "./dist/mini.js"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc -p tsconfig.build.json",
|
|
41
|
+
"test": "c8 tsx --test --experimental-test-module-mocks --no-warnings=ExperimentalWarning",
|
|
42
|
+
"test:ci": "c8 --reporter=lcov tsx --test --experimental-test-module-mocks --no-warnings=ExperimentalWarning",
|
|
43
|
+
"format": "biome format . --write",
|
|
44
|
+
"check": "biome check . --write"
|
|
43
45
|
},
|
|
44
46
|
"peerDependencies": {
|
|
45
47
|
"@js-joda/core": "^3.2.0 || ^4.0.0 || ^5.0.0",
|
|
46
|
-
"zod": "^3.
|
|
48
|
+
"zod": "^3.25.56"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"@zod/mini": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"zod": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
47
57
|
},
|
|
48
58
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"nyc": "^15.1.0",
|
|
63
|
-
"pinst": "^2.1.6",
|
|
64
|
-
"rimraf": "^3.0.2",
|
|
65
|
-
"ts-node": "^10.2.1",
|
|
66
|
-
"typescript": "^4.1.3",
|
|
67
|
-
"zod": "^3.8.7"
|
|
68
|
-
}
|
|
59
|
+
"@biomejs/biome": "^1.9.4",
|
|
60
|
+
"@commitlint/cli": "^19.8.1",
|
|
61
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
62
|
+
"@js-joda/core": "^5.6.5",
|
|
63
|
+
"@tsconfig/node22": "^22.0.2",
|
|
64
|
+
"@types/node": "^22.15.30",
|
|
65
|
+
"c8": "^10.1.3",
|
|
66
|
+
"lefthook": "^1.11.13",
|
|
67
|
+
"tsx": "^4.19.4",
|
|
68
|
+
"typescript": "^5.8.3",
|
|
69
|
+
"zod": "^3.25.56"
|
|
70
|
+
},
|
|
71
|
+
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
|
|
69
72
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DateTimeFormatter, LocalDate } from '@js-joda/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
declare type Parameters = {
|
|
4
|
-
dateTimeFormatter?: DateTimeFormatter;
|
|
5
|
-
};
|
|
6
|
-
export declare const localDate: (parameters?: Parameters | undefined) => z.ZodUnion<[z.ZodType<LocalDate, z.ZodTypeDef, LocalDate>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, LocalDate, string>]>;
|
|
7
|
-
export {};
|
package/lib/ZodJodaLocalDate.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localDate = void 0;
|
|
4
|
-
const core_1 = require("@js-joda/core");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const localDate = (parameters) => zod_1.z.union([
|
|
7
|
-
zod_1.z.custom(value => value instanceof core_1.LocalDate),
|
|
8
|
-
zod_1.z.string().refine(value => {
|
|
9
|
-
try {
|
|
10
|
-
core_1.LocalDate.parse(value, parameters === null || parameters === void 0 ? void 0 : parameters.dateTimeFormatter);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch (_a) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}, 'Invalid local date').transform(value => core_1.LocalDate.parse(value, parameters === null || parameters === void 0 ? void 0 : parameters.dateTimeFormatter))
|
|
17
|
-
]);
|
|
18
|
-
exports.localDate = localDate;
|
|
19
|
-
//# sourceMappingURL=ZodJodaLocalDate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ZodJodaLocalDate.js","sourceRoot":"","sources":["../src/ZodJodaLocalDate.ts"],"names":[],"mappings":";;;AAAA,wCAA2D;AAC3D,6BAAsB;AAMf,MAAM,SAAS,GAAG,CAAC,UAAwB,EAAE,EAAE,CAAC,OAAC,CAAC,KAAK,CAAC;IAC3D,OAAC,CAAC,MAAM,CAAY,KAAK,CAAC,EAAE,CAAC,KAAK,YAAY,gBAAS,CAAC;IACxD,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CACb,KAAK,CAAC,EAAE;QACJ,IAAI;YACA,gBAAS,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC;SACf;QAAC,WAAM;YACJ,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EAAE,oBAAoB,CAC1B,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,gBAAS,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,CAAC,CAAC;CAC9E,CAAC,CAAC;AAZU,QAAA,SAAS,aAYnB"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DateTimeFormatter, LocalDateTime } from '@js-joda/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
declare type Parameters = {
|
|
4
|
-
dateTimeFormatter?: DateTimeFormatter;
|
|
5
|
-
};
|
|
6
|
-
export declare const localDateTime: (parameters?: Parameters | undefined) => z.ZodUnion<[z.ZodType<LocalDateTime, z.ZodTypeDef, LocalDateTime>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, LocalDateTime, string>]>;
|
|
7
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localDateTime = void 0;
|
|
4
|
-
const core_1 = require("@js-joda/core");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const localDateTime = (parameters) => zod_1.z.union([
|
|
7
|
-
zod_1.z.custom(value => value instanceof core_1.LocalDateTime),
|
|
8
|
-
zod_1.z.string().refine(value => {
|
|
9
|
-
try {
|
|
10
|
-
core_1.LocalDateTime.parse(value, parameters === null || parameters === void 0 ? void 0 : parameters.dateTimeFormatter);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch (_a) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}, 'Invalid local date time').transform(value => core_1.LocalDateTime.parse(value, parameters === null || parameters === void 0 ? void 0 : parameters.dateTimeFormatter))
|
|
17
|
-
]);
|
|
18
|
-
exports.localDateTime = localDateTime;
|
|
19
|
-
//# sourceMappingURL=ZodJodaLocalDateTime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ZodJodaLocalDateTime.js","sourceRoot":"","sources":["../src/ZodJodaLocalDateTime.ts"],"names":[],"mappings":";;;AAAA,wCAA+D;AAC/D,6BAAsB;AAMf,MAAM,aAAa,GAAG,CAAC,UAAwB,EAAE,EAAE,CAAC,OAAC,CAAC,KAAK,CAAC;IAC/D,OAAC,CAAC,MAAM,CAAgB,KAAK,CAAC,EAAE,CAAC,KAAK,YAAY,oBAAa,CAAC;IAChE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CACb,KAAK,CAAC,EAAE;QACJ,IAAI;YACA,oBAAa,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,CAAC,CAAC;YAC1D,OAAO,IAAI,CAAC;SACf;QAAC,WAAM;YACJ,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EAAE,yBAAyB,CAC/B,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,oBAAa,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,CAAC,CAAC;CAClF,CAAC,CAAC;AAZU,QAAA,aAAa,iBAYvB"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DateTimeFormatter, LocalTime } from '@js-joda/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
declare type Parameters = {
|
|
4
|
-
dateTimeFormatter?: DateTimeFormatter;
|
|
5
|
-
};
|
|
6
|
-
export declare const localTime: (parameters?: Parameters | undefined) => z.ZodUnion<[z.ZodType<LocalTime, z.ZodTypeDef, LocalTime>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, LocalTime, string>]>;
|
|
7
|
-
export {};
|
package/lib/ZodJodaLocalTime.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localTime = void 0;
|
|
4
|
-
const core_1 = require("@js-joda/core");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const localTime = (parameters) => zod_1.z.union([
|
|
7
|
-
zod_1.z.custom(value => value instanceof core_1.LocalTime),
|
|
8
|
-
zod_1.z.string().refine(value => {
|
|
9
|
-
try {
|
|
10
|
-
core_1.LocalTime.parse(value, parameters === null || parameters === void 0 ? void 0 : parameters.dateTimeFormatter);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch (_a) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}, 'Invalid local time').transform(value => core_1.LocalTime.parse(value, parameters === null || parameters === void 0 ? void 0 : parameters.dateTimeFormatter))
|
|
17
|
-
]);
|
|
18
|
-
exports.localTime = localTime;
|
|
19
|
-
//# sourceMappingURL=ZodJodaLocalTime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ZodJodaLocalTime.js","sourceRoot":"","sources":["../src/ZodJodaLocalTime.ts"],"names":[],"mappings":";;;AAAA,wCAA2D;AAC3D,6BAAsB;AAMf,MAAM,SAAS,GAAG,CAAC,UAAwB,EAAE,EAAE,CAAC,OAAC,CAAC,KAAK,CAAC;IAC3D,OAAC,CAAC,MAAM,CAAY,KAAK,CAAC,EAAE,CAAC,KAAK,YAAY,gBAAS,CAAC;IACxD,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CACb,KAAK,CAAC,EAAE;QACJ,IAAI;YACA,gBAAS,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC;SACf;QAAC,WAAM;YACJ,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EAAE,oBAAoB,CAC1B,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,gBAAS,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,CAAC,CAAC;CAC9E,CAAC,CAAC;AAZU,QAAA,SAAS,aAYnB"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DateTimeFormatter, ZonedDateTime } from '@js-joda/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
declare type Parameters = {
|
|
4
|
-
dateTimeFormatter?: DateTimeFormatter;
|
|
5
|
-
};
|
|
6
|
-
export declare const zonedDateTime: (parameters?: Parameters | undefined) => z.ZodUnion<[z.ZodType<ZonedDateTime, z.ZodTypeDef, ZonedDateTime>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, ZonedDateTime, string>]>;
|
|
7
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zonedDateTime = void 0;
|
|
4
|
-
const core_1 = require("@js-joda/core");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const zonedDateTime = (parameters) => zod_1.z.union([
|
|
7
|
-
zod_1.z.custom(value => value instanceof core_1.ZonedDateTime),
|
|
8
|
-
zod_1.z.string().refine(value => {
|
|
9
|
-
try {
|
|
10
|
-
core_1.ZonedDateTime.parse(value, parameters === null || parameters === void 0 ? void 0 : parameters.dateTimeFormatter);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch (_a) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}, 'Invalid zoned date time').transform(value => core_1.ZonedDateTime.parse(value, parameters === null || parameters === void 0 ? void 0 : parameters.dateTimeFormatter))
|
|
17
|
-
]);
|
|
18
|
-
exports.zonedDateTime = zonedDateTime;
|
|
19
|
-
//# sourceMappingURL=ZodJodaZonedDateTime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ZodJodaZonedDateTime.js","sourceRoot":"","sources":["../src/ZodJodaZonedDateTime.ts"],"names":[],"mappings":";;;AAAA,wCAA+D;AAC/D,6BAAsB;AAMf,MAAM,aAAa,GAAG,CAAC,UAAwB,EAAE,EAAE,CAAC,OAAC,CAAC,KAAK,CAAC;IAC/D,OAAC,CAAC,MAAM,CAAgB,KAAK,CAAC,EAAE,CAAC,KAAK,YAAY,oBAAa,CAAC;IAChE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CACb,KAAK,CAAC,EAAE;QACJ,IAAI;YACA,oBAAa,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,CAAC,CAAC;YAC1D,OAAO,IAAI,CAAC;SACf;QAAC,WAAM;YACJ,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EAAE,yBAAyB,CAC/B,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,oBAAa,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,CAAC,CAAC;CAClF,CAAC,CAAC;AAZU,QAAA,aAAa,iBAYvB"}
|
package/lib/index.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare const all: {
|
|
2
|
-
zonedDateTime: (parameters?: {
|
|
3
|
-
dateTimeFormatter?: import("@js-joda/core").DateTimeFormatter | undefined;
|
|
4
|
-
} | undefined) => import("zod").ZodUnion<[import("zod").ZodType<import("@js-joda/core").ZonedDateTime, import("zod").ZodTypeDef, import("@js-joda/core").ZonedDateTime>, import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("@js-joda/core").ZonedDateTime, string>]>;
|
|
5
|
-
localTime: (parameters?: {
|
|
6
|
-
dateTimeFormatter?: import("@js-joda/core").DateTimeFormatter | undefined;
|
|
7
|
-
} | undefined) => import("zod").ZodUnion<[import("zod").ZodType<import("@js-joda/core").LocalTime, import("zod").ZodTypeDef, import("@js-joda/core").LocalTime>, import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("@js-joda/core").LocalTime, string>]>;
|
|
8
|
-
localDateTime: (parameters?: {
|
|
9
|
-
dateTimeFormatter?: import("@js-joda/core").DateTimeFormatter | undefined;
|
|
10
|
-
} | undefined) => import("zod").ZodUnion<[import("zod").ZodType<import("@js-joda/core").LocalDateTime, import("zod").ZodTypeDef, import("@js-joda/core").LocalDateTime>, import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("@js-joda/core").LocalDateTime, string>]>;
|
|
11
|
-
localDate: (parameters?: {
|
|
12
|
-
dateTimeFormatter?: import("@js-joda/core").DateTimeFormatter | undefined;
|
|
13
|
-
} | undefined) => import("zod").ZodUnion<[import("zod").ZodType<import("@js-joda/core").LocalDate, import("zod").ZodTypeDef, import("@js-joda/core").LocalDate>, import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("@js-joda/core").LocalDate, string>]>;
|
|
14
|
-
};
|
|
15
|
-
export declare const zj: {
|
|
16
|
-
zonedDateTime: (parameters?: {
|
|
17
|
-
dateTimeFormatter?: import("@js-joda/core").DateTimeFormatter | undefined;
|
|
18
|
-
} | undefined) => import("zod").ZodUnion<[import("zod").ZodType<import("@js-joda/core").ZonedDateTime, import("zod").ZodTypeDef, import("@js-joda/core").ZonedDateTime>, import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("@js-joda/core").ZonedDateTime, string>]>;
|
|
19
|
-
localTime: (parameters?: {
|
|
20
|
-
dateTimeFormatter?: import("@js-joda/core").DateTimeFormatter | undefined;
|
|
21
|
-
} | undefined) => import("zod").ZodUnion<[import("zod").ZodType<import("@js-joda/core").LocalTime, import("zod").ZodTypeDef, import("@js-joda/core").LocalTime>, import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("@js-joda/core").LocalTime, string>]>;
|
|
22
|
-
localDateTime: (parameters?: {
|
|
23
|
-
dateTimeFormatter?: import("@js-joda/core").DateTimeFormatter | undefined;
|
|
24
|
-
} | undefined) => import("zod").ZodUnion<[import("zod").ZodType<import("@js-joda/core").LocalDateTime, import("zod").ZodTypeDef, import("@js-joda/core").LocalDateTime>, import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("@js-joda/core").LocalDateTime, string>]>;
|
|
25
|
-
localDate: (parameters?: {
|
|
26
|
-
dateTimeFormatter?: import("@js-joda/core").DateTimeFormatter | undefined;
|
|
27
|
-
} | undefined) => import("zod").ZodUnion<[import("zod").ZodType<import("@js-joda/core").LocalDate, import("zod").ZodTypeDef, import("@js-joda/core").LocalDate>, import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("@js-joda/core").LocalDate, string>]>;
|
|
28
|
-
};
|
|
29
|
-
export default all;
|
package/lib/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zj = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const localDate = (0, tslib_1.__importStar)(require("./ZodJodaLocalDate"));
|
|
6
|
-
const localDateTime = (0, tslib_1.__importStar)(require("./ZodJodaLocalDateTime"));
|
|
7
|
-
const localTime = (0, tslib_1.__importStar)(require("./ZodJodaLocalTime"));
|
|
8
|
-
const zonedDateTime = (0, tslib_1.__importStar)(require("./ZodJodaZonedDateTime"));
|
|
9
|
-
const all = {
|
|
10
|
-
...localDate,
|
|
11
|
-
...localDateTime,
|
|
12
|
-
...localTime,
|
|
13
|
-
...zonedDateTime,
|
|
14
|
-
};
|
|
15
|
-
exports.zj = all;
|
|
16
|
-
exports.default = all;
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,2EAAgD;AAChD,mFAAwD;AACxD,2EAAgD;AAChD,mFAAwD;AAExD,MAAM,GAAG,GAAG;IACR,GAAG,SAAS;IACZ,GAAG,aAAa;IAChB,GAAG,SAAS;IACZ,GAAG,aAAa;CACnB,CAAC;AAEW,QAAA,EAAE,GAAG,GAAG,CAAC;AACtB,kBAAe,GAAG,CAAC"}
|