@better-giving/schemas 1.2.1 → 1.2.3
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 +3 -0
- package/dist/index.mjs +8 -1
- package/package.json +1 -1
- package/src/index.mts +25 -3
package/dist/index.d.mts
CHANGED
|
@@ -26,3 +26,6 @@ export declare const $num_gt0_fn: ({ required, }?: {
|
|
|
26
26
|
required?: boolean;
|
|
27
27
|
}) => import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>, import("valibot").TransformAction<string, number>, import("valibot").NumberSchema<"invalid number">, import("valibot").MinValueAction<number, 0, "must be > 0">, import("valibot").TransformAction<number, string>]>>;
|
|
28
28
|
export declare const https_url: (non_empty: boolean) => import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").TransformAction<string, string>, import("valibot").UrlAction<string, "invalid url">]>>;
|
|
29
|
+
export declare const segment_max_chars = 30;
|
|
30
|
+
export declare const segment: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").MaxLengthAction<string, 30, ({ requirement: r }: import("valibot").MaxLengthIssue<string, 30>) => string>, import("valibot").RegexAction<string, "should not be an id">, import("valibot").RegexAction<string, "allowed: numbers | letters | - | . | _ | ~">, import("valibot").ExcludesAction<string, "..", "should not contain double periods">, import("valibot").CustomSchema<string, "should not start with dot">, import("valibot").CustomSchema<string, "should not end with dot">]>;
|
|
31
|
+
export declare const slug: import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").MaxLengthAction<string, 30, ({ requirement: r }: import("valibot").MaxLengthIssue<string, 30>) => string>, import("valibot").RegexAction<string, "should not be an id">, import("valibot").RegexAction<string, "allowed: numbers | letters | - | . | _ | ~">, import("valibot").ExcludesAction<string, "..", "should not contain double periods">, import("valibot").CustomSchema<string, "should not start with dot">, import("valibot").CustomSchema<string, "should not end with dot">]>>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { url, lazy, nonEmpty, object, picklist, pipe, string, transform, trim,
|
|
1
|
+
import { url, integer, lazy, minValue, nonEmpty, number, object, picklist, pipe, string, transform, trim, maxLength, custom, regex, excludes, } from "valibot";
|
|
2
2
|
export const file_obj = object({
|
|
3
3
|
name: string(),
|
|
4
4
|
publicUrl: pipe(string(), url()),
|
|
@@ -40,3 +40,10 @@ export const https_url = (non_empty) => {
|
|
|
40
40
|
return pipe($, transform((x) => (x.startsWith("https://") ? x : `https://${x}`)), url("invalid url"));
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
|
+
export const segment_max_chars = 30;
|
|
44
|
+
export const segment = pipe($, maxLength(segment_max_chars, ({ requirement: r }) => `cannot exceed ${r} chars`),
|
|
45
|
+
//must not be id-like
|
|
46
|
+
regex(/^(?!^\d+$)/, "should not be an id"),
|
|
47
|
+
//valid characters
|
|
48
|
+
regex(/^[a-zA-Z0-9-._~]+$/, "allowed: numbers | letters | - | . | _ | ~"), excludes("..", "should not contain double periods"), custom((x) => !x.startsWith("."), "should not start with dot"), custom((x) => !x.endsWith("."), "should not end with dot"));
|
|
49
|
+
export const slug = lazy((x) => (x ? segment : $));
|
package/package.json
CHANGED
package/src/index.mts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
url,
|
|
3
3
|
type InferOutput,
|
|
4
|
+
integer,
|
|
4
5
|
lazy,
|
|
6
|
+
minValue,
|
|
5
7
|
nonEmpty,
|
|
8
|
+
number,
|
|
6
9
|
object,
|
|
7
10
|
picklist,
|
|
8
11
|
pipe,
|
|
9
12
|
string,
|
|
10
13
|
transform,
|
|
11
14
|
trim,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
maxLength,
|
|
16
|
+
custom,
|
|
17
|
+
regex,
|
|
18
|
+
excludes,
|
|
15
19
|
} from "valibot";
|
|
16
20
|
|
|
17
21
|
export const file_obj = object({
|
|
@@ -85,3 +89,21 @@ export const https_url = (non_empty: boolean) => {
|
|
|
85
89
|
);
|
|
86
90
|
});
|
|
87
91
|
};
|
|
92
|
+
|
|
93
|
+
export const segment_max_chars = 30;
|
|
94
|
+
export const segment = pipe(
|
|
95
|
+
$,
|
|
96
|
+
maxLength(
|
|
97
|
+
segment_max_chars,
|
|
98
|
+
({ requirement: r }) => `cannot exceed ${r} chars`
|
|
99
|
+
),
|
|
100
|
+
//must not be id-like
|
|
101
|
+
regex(/^(?!^\d+$)/, "should not be an id"),
|
|
102
|
+
//valid characters
|
|
103
|
+
regex(/^[a-zA-Z0-9-._~]+$/, "allowed: numbers | letters | - | . | _ | ~"),
|
|
104
|
+
excludes("..", "should not contain double periods"),
|
|
105
|
+
custom((x) => !(x as string).startsWith("."), "should not start with dot"),
|
|
106
|
+
custom((x) => !(x as string).endsWith("."), "should not end with dot")
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
export const slug = lazy((x) => (x ? segment : $));
|