@awsless/validate 0.0.8 → 0.0.9

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/dist/index.cjs CHANGED
@@ -119,17 +119,12 @@ var uuid = (error) => {
119
119
  var import_valibot5 = require("valibot");
120
120
  var import_duration = require("@awsless/duration");
121
121
  function duration(arg1, arg2) {
122
- const [error, pipe] = (0, import_valibot5.getDefaultArgs)(arg1, arg2);
123
- return (0, import_valibot5.union)(
124
- [
125
- (0, import_valibot5.transform)(
126
- (0, import_valibot5.string)([(0, import_valibot5.regex)(/^[0-9]+ (milliseconds?|seconds?|minutes?|hours?|days?)/)]),
127
- (value) => (0, import_duration.parse)(value),
128
- pipe
129
- ),
130
- (0, import_valibot5.instance)(import_duration.Duration, pipe)
131
- ],
132
- error ?? "Invalid duration"
122
+ const [msg, pipe] = (0, import_valibot5.getDefaultArgs)(arg1, arg2);
123
+ const error = msg ?? "Invalid duration";
124
+ return (0, import_valibot5.transform)(
125
+ (0, import_valibot5.string)(error, [(0, import_valibot5.regex)(/^[0-9]+ (milliseconds?|seconds?|minutes?|hours?|days?)/)]),
126
+ (value) => (0, import_duration.parse)(value),
127
+ pipe
133
128
  );
134
129
  }
135
130
 
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseSchema, SchemaWithTransform, StringSchema, Output, Pipe, ErrorMessage, UnionSchema, InstanceSchema, UnknownSchema, Input, PipeResult } from 'valibot';
1
+ import { BaseSchema, SchemaWithTransform, StringSchema, Output, Pipe, ErrorMessage, UnknownSchema, Input, PipeResult } from 'valibot';
2
2
  export * from 'valibot';
3
3
  import { BigFloat } from '@awsless/big-float';
4
4
  import { UUID } from 'crypto';
@@ -22,10 +22,7 @@ declare function date(error?: ErrorMessage, pipe?: Pipe<Date>): DateSchema;
22
22
  type UuidSchema = SchemaWithTransform<StringSchema | BaseSchema<UUID>, UUID>;
23
23
  declare const uuid: (error?: ErrorMessage) => UuidSchema;
24
24
 
25
- type DurationSchema = UnionSchema<[
26
- SchemaWithTransform<StringSchema | BaseSchema<DurationFormat, Duration>, Duration>,
27
- InstanceSchema<typeof Duration>
28
- ], Duration>;
25
+ type DurationSchema = BaseSchema<DurationFormat, Duration>;
29
26
  declare function duration(pipe?: Pipe<Duration>): DurationSchema;
30
27
  declare function duration(error?: ErrorMessage, pipe?: Pipe<Duration>): DurationSchema;
31
28
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseSchema, SchemaWithTransform, StringSchema, Output, Pipe, ErrorMessage, UnionSchema, InstanceSchema, UnknownSchema, Input, PipeResult } from 'valibot';
1
+ import { BaseSchema, SchemaWithTransform, StringSchema, Output, Pipe, ErrorMessage, UnknownSchema, Input, PipeResult } from 'valibot';
2
2
  export * from 'valibot';
3
3
  import { BigFloat } from '@awsless/big-float';
4
4
  import { UUID } from 'crypto';
@@ -22,10 +22,7 @@ declare function date(error?: ErrorMessage, pipe?: Pipe<Date>): DateSchema;
22
22
  type UuidSchema = SchemaWithTransform<StringSchema | BaseSchema<UUID>, UUID>;
23
23
  declare const uuid: (error?: ErrorMessage) => UuidSchema;
24
24
 
25
- type DurationSchema = UnionSchema<[
26
- SchemaWithTransform<StringSchema | BaseSchema<DurationFormat, Duration>, Duration>,
27
- InstanceSchema<typeof Duration>
28
- ], Duration>;
25
+ type DurationSchema = BaseSchema<DurationFormat, Duration>;
29
26
  declare function duration(pipe?: Pipe<Duration>): DurationSchema;
30
27
  declare function duration(error?: ErrorMessage, pipe?: Pipe<Duration>): DurationSchema;
31
28
 
package/dist/index.js CHANGED
@@ -94,35 +94,23 @@ var uuid = (error) => {
94
94
  };
95
95
 
96
96
  // src/schema/duration.ts
97
- import {
98
- getDefaultArgs as getDefaultArgs3,
99
- instance as instance2,
100
- regex,
101
- string as string5,
102
- transform as transform5,
103
- union as union3
104
- } from "valibot";
105
- import { Duration, parse } from "@awsless/duration";
97
+ import { getDefaultArgs as getDefaultArgs3, regex, string as string5, transform as transform5 } from "valibot";
98
+ import { parse } from "@awsless/duration";
106
99
  function duration(arg1, arg2) {
107
- const [error, pipe] = getDefaultArgs3(arg1, arg2);
108
- return union3(
109
- [
110
- transform5(
111
- string5([regex(/^[0-9]+ (milliseconds?|seconds?|minutes?|hours?|days?)/)]),
112
- (value) => parse(value),
113
- pipe
114
- ),
115
- instance2(Duration, pipe)
116
- ],
117
- error ?? "Invalid duration"
100
+ const [msg, pipe] = getDefaultArgs3(arg1, arg2);
101
+ const error = msg ?? "Invalid duration";
102
+ return transform5(
103
+ string5(error, [regex(/^[0-9]+ (milliseconds?|seconds?|minutes?|hours?|days?)/)]),
104
+ (value) => parse(value),
105
+ pipe
118
106
  );
119
107
  }
120
108
 
121
109
  // src/schema/aws/sqs-queue.ts
122
- import { array, object as object2, transform as transform6, union as union4, unknown } from "valibot";
110
+ import { array, object as object2, transform as transform6, union as union3, unknown } from "valibot";
123
111
  var sqsQueue = (body) => {
124
112
  const schema = body ?? unknown();
125
- return union4(
113
+ return union3(
126
114
  [
127
115
  transform6(schema, (input) => [input]),
128
116
  array(schema),
@@ -144,10 +132,10 @@ var sqsQueue = (body) => {
144
132
  };
145
133
 
146
134
  // src/schema/aws/sns-topic.ts
147
- import { array as array2, object as object3, transform as transform7, union as union5, unknown as unknown2 } from "valibot";
135
+ import { array as array2, object as object3, transform as transform7, union as union4, unknown as unknown2 } from "valibot";
148
136
  var snsTopic = (body) => {
149
137
  const schema = body ?? unknown2();
150
- return union5(
138
+ return union4(
151
139
  [
152
140
  transform7(schema, (input) => [input]),
153
141
  array2(schema),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/validate",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@awsless/big-float": "^0.0.4",
33
- "@awsless/duration": "^0.0.1",
34
- "@awsless/dynamodb": "^0.0.40"
33
+ "@awsless/dynamodb": "^0.0.40",
34
+ "@awsless/duration": "^0.0.1"
35
35
  },
36
36
  "dependencies": {
37
37
  "valibot": "^0.20.1"