@better-giving/schemas 2.2.0 → 2.3.1
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.d.mts +5 -0
- package/dist/index.mjs +5 -1
- package/package.json +4 -4
- package/src/index.mts +28 -0
package/dist/index.d.mts
CHANGED
|
@@ -43,3 +43,8 @@ export declare const increment: import("valibot").ObjectSchema<{
|
|
|
43
43
|
export interface IIncrement extends InferOutput<typeof increment> {
|
|
44
44
|
}
|
|
45
45
|
export declare const target: import("valibot").UnionSchema<[import("valibot").LiteralSchema<"smart", undefined>, import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TransformAction<string, number>, import("valibot").NumberSchema<undefined>, import("valibot").MinValueAction<number, 0, undefined>, import("valibot").TransformAction<number, string>]>], undefined>;
|
|
46
|
+
export declare const frequencies: readonly ["one-time", "monthly", "weekly", "annual"];
|
|
47
|
+
export declare const frequency: import("valibot").PicklistSchema<readonly ["one-time", "monthly", "weekly", "annual"], "Please select donation frequency">;
|
|
48
|
+
export declare const donate_freq_opts: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").PicklistSchema<readonly ["one-time", "monthly", "weekly", "annual"], "Please select donation frequency">, undefined>, import("valibot").TransformAction<("one-time" | "monthly" | "weekly" | "annual")[], ("one-time" | "monthly" | "weekly" | "annual")[]>, import("valibot").MinLengthAction<("one-time" | "monthly" | "weekly" | "annual")[], 1, "at least one frequency must be selected">, import("valibot").CheckAction<("one-time" | "monthly" | "weekly" | "annual")[], "should allow one-time donations">]>;
|
|
49
|
+
export declare const donate_freq_opts_bool: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").BooleanSchema<undefined>, undefined>, import("valibot").LengthAction<boolean[], 4, "should have four frequency options">, import("valibot").SomeItemAction<boolean[], "select at least one">, import("valibot").CheckAction<boolean[], "should allow one-time donations">]>;
|
|
50
|
+
export type TFrequency = InferOutput<typeof frequency>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { url, custom, excludes, integer, lazy, literal, maxLength, minValue, nonEmpty, number, object, picklist, pipe, regex, string, transform, trim, union, } from "valibot";
|
|
1
|
+
import { url, array, custom, excludes, integer, lazy, literal, maxLength, minLength, minValue, nonEmpty, number, object, picklist, pipe, regex, string, transform, trim, union, boolean, length, someItem, check, } from "valibot";
|
|
2
2
|
export const file_obj = object({
|
|
3
3
|
name: string(),
|
|
4
4
|
publicUrl: pipe(string(), url()),
|
|
@@ -63,3 +63,7 @@ export const target = union([
|
|
|
63
63
|
// "0" - none, `${number}` - fixed
|
|
64
64
|
pipe(string(), transform((v) => +v), number(), minValue(0), transform((v) => v.toString())),
|
|
65
65
|
]);
|
|
66
|
+
export const frequencies = ["one-time", "monthly", "weekly", "annual"];
|
|
67
|
+
export const frequency = picklist(frequencies, "Please select donation frequency");
|
|
68
|
+
export const donate_freq_opts = pipe(array(frequency), transform((x) => Array.from(new Set(x))), minLength(1, "at least one frequency must be selected"), check((x) => x.includes("one-time"), "should allow one-time donations"));
|
|
69
|
+
export const donate_freq_opts_bool = pipe(array(boolean()), length(4, "should have four frequency options"), someItem((x) => x, "select at least one"), check(([one_time]) => one_time, "should allow one-time donations"));
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-giving/schemas",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"devDependencies": {
|
|
5
|
-
"@better-giving/config": "1.
|
|
5
|
+
"@better-giving/config": "^1.0.0"
|
|
6
6
|
},
|
|
7
7
|
"files": [
|
|
8
8
|
"src",
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"valibot": "1.
|
|
12
|
+
"valibot": "^1.0.0"
|
|
13
13
|
},
|
|
14
14
|
"optionalDependencies": {
|
|
15
|
-
"date-fns": "4.
|
|
15
|
+
"date-fns": "^4.0.0"
|
|
16
16
|
},
|
|
17
17
|
"exports": {
|
|
18
18
|
".": "./dist/index.mjs",
|
package/src/index.mts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
url,
|
|
3
3
|
type InferOutput,
|
|
4
|
+
array,
|
|
4
5
|
custom,
|
|
5
6
|
excludes,
|
|
6
7
|
integer,
|
|
7
8
|
lazy,
|
|
8
9
|
literal,
|
|
9
10
|
maxLength,
|
|
11
|
+
minLength,
|
|
10
12
|
minValue,
|
|
11
13
|
nonEmpty,
|
|
12
14
|
number,
|
|
@@ -18,6 +20,10 @@ import {
|
|
|
18
20
|
transform,
|
|
19
21
|
trim,
|
|
20
22
|
union,
|
|
23
|
+
boolean,
|
|
24
|
+
length,
|
|
25
|
+
someItem,
|
|
26
|
+
check,
|
|
21
27
|
} from "valibot";
|
|
22
28
|
|
|
23
29
|
export const file_obj = object({
|
|
@@ -146,3 +152,25 @@ export const target = union([
|
|
|
146
152
|
transform((v) => v.toString())
|
|
147
153
|
),
|
|
148
154
|
]);
|
|
155
|
+
|
|
156
|
+
export const frequencies = ["one-time", "monthly", "weekly", "annual"] as const;
|
|
157
|
+
export const frequency = picklist(
|
|
158
|
+
frequencies,
|
|
159
|
+
"Please select donation frequency"
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
export const donate_freq_opts = pipe(
|
|
163
|
+
array(frequency),
|
|
164
|
+
transform((x) => Array.from(new Set(x))),
|
|
165
|
+
minLength(1, "at least one frequency must be selected"),
|
|
166
|
+
check((x) => x.includes("one-time"), "should allow one-time donations")
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
export const donate_freq_opts_bool = pipe(
|
|
170
|
+
array(boolean()),
|
|
171
|
+
length(4, "should have four frequency options"),
|
|
172
|
+
someItem((x) => x, "select at least one"),
|
|
173
|
+
check(([one_time]) => one_time, "should allow one-time donations")
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
export type TFrequency = InferOutput<typeof frequency>;
|