@better-giving/schemas 2.3.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 CHANGED
@@ -45,5 +45,6 @@ export interface IIncrement extends InferOutput<typeof increment> {
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
46
  export declare const frequencies: readonly ["one-time", "monthly", "weekly", "annual"];
47
47
  export declare const frequency: import("valibot").PicklistSchema<readonly ["one-time", "monthly", "weekly", "annual"], "Please select donation frequency">;
48
- export declare const frequency_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">]>;
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">]>;
49
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, array, minLength, } 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()),
@@ -65,4 +65,5 @@ export const target = union([
65
65
  ]);
66
66
  export const frequencies = ["one-time", "monthly", "weekly", "annual"];
67
67
  export const frequency = picklist(frequencies, "Please select donation frequency");
68
- export const frequency_opts = pipe(array(frequency), transform((x) => Array.from(new Set(x))), minLength(1, "at least one frequency must be selected"));
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/schemas",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "devDependencies": {
5
5
  "@better-giving/config": "^1.0.0"
6
6
  },
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,8 +20,10 @@ import {
18
20
  transform,
19
21
  trim,
20
22
  union,
21
- array,
22
- minLength,
23
+ boolean,
24
+ length,
25
+ someItem,
26
+ check,
23
27
  } from "valibot";
24
28
 
25
29
  export const file_obj = object({
@@ -155,10 +159,18 @@ export const frequency = picklist(
155
159
  "Please select donation frequency"
156
160
  );
157
161
 
158
- export const frequency_opts = pipe(
162
+ export const donate_freq_opts = pipe(
159
163
  array(frequency),
160
164
  transform((x) => Array.from(new Set(x))),
161
- minLength(1, "at least one frequency must be selected")
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")
162
174
  );
163
175
 
164
176
  export type TFrequency = InferOutput<typeof frequency>;