@whatsaaaa/form-builder-schema 0.2.0 → 0.3.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/README.md +61 -3
- package/dist/index.d.ts +379 -12
- package/dist/index.js +516 -35
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@ Build [Valibot](https://valibot.dev) schemas from JSON form definitions, ready t
|
|
|
8
8
|
pnpm add @whatsaaaa/form-builder-schema valibot
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
Valibot 1.3 or later is required.
|
|
12
|
+
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
15
|
```ts
|
|
@@ -30,9 +32,55 @@ const { build, validate } = createSchemaBuilder()
|
|
|
30
32
|
const schema = build(json) // v.ObjectSchema, ready for Formisch or v.parse
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
Built-in field types are `text`, `email`, `password` and `number`.
|
|
35
|
+
Built-in field types are `text`, `email`, `password` and `number`. Empty optional fields output `undefined`. Rules never run on empty values, and a required empty field reports only the required message.
|
|
36
|
+
|
|
37
|
+
## Rules
|
|
38
|
+
|
|
39
|
+
Every Valibot action whose arguments fit in JSON is a rule with the same name. Params go next to `rule`, and a rule without a `message` uses Valibot's message, so [`@valibot/i18n`](https://valibot.dev/guides/internationalization/) works.
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{ "rule": "minLength", "value": 3, "message": "At least 3 characters" }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Family | Rules | Kinds | Params |
|
|
46
|
+
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ | -------------------------------------- |
|
|
47
|
+
| `lengthRules` | `length` `minLength` `maxLength` `notLength` | string, array | `value` |
|
|
48
|
+
| `textUnitRules` | `graphemes` `minGraphemes` `maxGraphemes` `notGraphemes`, `words` `minWords` `maxWords` `notWords`, `bytes` `minBytes` `maxBytes` `notBytes` | string | `value`; words also `locale` |
|
|
49
|
+
| `contentRules` | `regex` `startsWith` `endsWith` `includes` `excludes` | string; `includes` and `excludes` also array | `pattern` and `flags`, or `value` |
|
|
50
|
+
| `formatRules` | `email` `rfcEmail` `url` `domain` `slug` `uuid` `ulid` `cuid2` `nanoid` `ip` `ipv4` `ipv6` `mac` `mac48` `mac64` `hexColor` `hexadecimal` `octal` `decimal` `digits` `base64` `bic` `creditCard` `imei` `isbn` `isrc` `emoji` `hash` | string | none; `hash` takes `types` |
|
|
51
|
+
| `dateRules` | `isoDate` `isoDateTime` `isoTime` `isoTimeSecond` `isoTimestamp` `isoWeek` | string, date | none |
|
|
52
|
+
| `comparisonRules` | `minValue` `maxValue` `gtValue` `ltValue` `value` `notValue` `values` `notValues` | number, date; `value` and `notValue` also string and boolean | `value` or `values`, typed by the kind |
|
|
53
|
+
| `numberRules` | `integer` `safeInteger` `finite` `multipleOf` | number | `multipleOf` takes `value` |
|
|
54
|
+
| `fileRules` | `minSize` `maxSize` `size` `notSize` `mimeType` | file | `value` in bytes, or `types` |
|
|
55
|
+
| `normalizeRules` | `trim` `trimStart` `trimEnd` `toLowerCase` `toUpperCase` `normalize`, `toMinValue` `toMaxValue` | string; `toMinValue` and `toMaxValue` on number | none; `form`, or `value` |
|
|
56
|
+
|
|
57
|
+
- **Normalize rules** change the value instead of checking it, and run before the required check. With `trim`, `' '` counts as empty.
|
|
58
|
+
- **`regex`** takes `pattern` (without slashes) and optional `flags`. A pattern `RegExp` rejects is an `invalid_params` issue. `g` and `y` are accepted but ignored, because they make a regex skip ahead on the next value. If end users write patterns, beware of [ReDoS](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS): a pattern like `(a+)+$` can freeze the page.
|
|
59
|
+
- **Comparing dates.** On a `date` field, `value` must be an ISO date, date-time or time string. Valibot compares them as text, so use the same format as the field: `'2026-01-01'` for a date, `'2026-01-01T09:00'` for a date-time.
|
|
60
|
+
- **`words`** splits text by language. Without `locale`, the runtime's default locale is used.
|
|
61
|
+
- Function-based actions (`check`, `transform`, …) can't be written in JSON. Register them as your own rules with `defineRule`.
|
|
62
|
+
|
|
63
|
+
### Registering only some rules
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { createSchemaBuilder, formatRules, lengthRules } from '@whatsaaaa/form-builder-schema'
|
|
67
|
+
|
|
68
|
+
const { build } = createSchemaBuilder({
|
|
69
|
+
includeDefaultRules: false,
|
|
70
|
+
rules: { ...formatRules, ...lengthRules },
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The built-in `email` type uses the `email` rule, so keep `formatRules` (or replace the `email` type), or `createSchemaBuilder` throws a `TypeError`.
|
|
34
75
|
|
|
35
|
-
|
|
76
|
+
### Listing rules
|
|
77
|
+
|
|
78
|
+
Every built-in rule has `meta` with a `label`, a `category` and sometimes a `description`, for a rule picker. `rulesForKind(kind)` returns the `[name, def]` pairs that fit a kind:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const { rulesForKind } = createSchemaBuilder()
|
|
82
|
+
rulesForKind('file').map(([name, def]) => def.meta?.label) // ['Minimum size', …]
|
|
83
|
+
```
|
|
36
84
|
|
|
37
85
|
## Checking definitions
|
|
38
86
|
|
|
@@ -69,7 +117,17 @@ const { build } = createSchemaBuilder({ fieldTypes: { select }, rules: { even }
|
|
|
69
117
|
```
|
|
70
118
|
|
|
71
119
|
- A **kind** says what "empty" means for a value (`isEmpty`) and adds an optional extra `required` check. Built-in kinds are `string`, `number`, `boolean`, `date`, `array`, `file`, `object` and `none`. A type with kind `none` has no value, like a heading.
|
|
72
|
-
- A **rule** with `stage: 'normalize'` runs before the required check. Its `params` schema lists the only keys the rule accepts.
|
|
120
|
+
- A **rule** with `stage: 'normalize'` runs before the required check. Its `params` schema lists the only keys the rule accepts. `params` can also be a function of the field's kind, for params whose type depends on it:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
const atLeast = defineRule({
|
|
124
|
+
kinds: ['number', 'date'],
|
|
125
|
+
params: (kind) => v.object({ value: kind === 'date' ? v.string() : v.number() }),
|
|
126
|
+
meta: { label: 'At least', category: 'comparison' },
|
|
127
|
+
create: (params, message) => v.minValue(params.value, message),
|
|
128
|
+
})
|
|
129
|
+
```
|
|
130
|
+
|
|
73
131
|
- Mistakes in the registry, such as an unknown kind or a reserved props key, throw a `TypeError` from `createSchemaBuilder`.
|
|
74
132
|
|
|
75
133
|
## Messages
|
package/dist/index.d.ts
CHANGED
|
@@ -85,13 +85,26 @@ interface BuildContext {
|
|
|
85
85
|
* as empty. `validate` rules run after it.
|
|
86
86
|
*/
|
|
87
87
|
type RuleStage = 'normalize' | 'validate';
|
|
88
|
+
/** Groups rules in the builder app. One per rule family. */
|
|
89
|
+
type RuleCategory = 'length' | 'text' | 'content' | 'format' | 'date' | 'comparison' | 'number' | 'file' | 'normalize';
|
|
90
|
+
/** Describes a rule to people, e.g. in the builder app's rule picker. */
|
|
91
|
+
interface RuleMeta {
|
|
92
|
+
label: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
category: RuleCategory;
|
|
95
|
+
}
|
|
88
96
|
interface RuleDef<TParams extends AnyObjectSchema = AnyObjectSchema> {
|
|
89
97
|
kinds: readonly ValueKind[];
|
|
90
98
|
/** Defaults to `'validate'`. */
|
|
91
99
|
stage?: RuleStage;
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
/**
|
|
101
|
+
* The params the rule takes. Omit it for rules without params. Unknown params are rejected.
|
|
102
|
+
* A function gets the field's kind, for params that depend on it (`minValue` takes a number
|
|
103
|
+
* on a number field, and an ISO string on a date field). It is called once per kind.
|
|
104
|
+
*/
|
|
105
|
+
params?: TParams | ((kind: ValueKind) => TParams);
|
|
106
|
+
meta?: RuleMeta;
|
|
107
|
+
/** Method syntax keeps `create` bivariant, so specific rules fit in a `Record<string, RuleDef>`. */
|
|
95
108
|
create(params: v.InferOutput<TParams>, message?: string): AnyAction;
|
|
96
109
|
}
|
|
97
110
|
interface MessageContext {
|
|
@@ -103,6 +116,7 @@ interface SchemaBuilderOptions {
|
|
|
103
116
|
kinds?: Record<string, KindDef>;
|
|
104
117
|
fieldTypes?: Record<string, FieldTypeDef>;
|
|
105
118
|
rules?: Record<string, RuleDef>;
|
|
119
|
+
includeDefaultRules?: boolean;
|
|
106
120
|
messages?: {
|
|
107
121
|
required?: string;
|
|
108
122
|
};
|
|
@@ -115,6 +129,7 @@ interface SchemaBuilderOptions {
|
|
|
115
129
|
export declare function createSchemaBuilder(options?: SchemaBuilderOptions): {
|
|
116
130
|
build: (json: JsonForm) => v.ObjectSchema<v.ObjectEntries, undefined>;
|
|
117
131
|
validate: (json: unknown) => ValidateResult;
|
|
132
|
+
rulesForKind: (kind: ValueKind) => [name: string, def: RuleDef][];
|
|
118
133
|
kinds: Readonly<Record<string, KindDef>>;
|
|
119
134
|
fieldTypes: Readonly<Record<string, FieldTypeDef<AnyObjectSchema>>>;
|
|
120
135
|
rules: Readonly<Record<string, RuleDef<AnyObjectSchema>>>;
|
|
@@ -171,29 +186,381 @@ export declare const defaultKinds: {
|
|
|
171
186
|
isEmpty: () => true;
|
|
172
187
|
};
|
|
173
188
|
};
|
|
189
|
+
/** Compares the value with a param of the same type. */
|
|
190
|
+
export declare const comparisonRules: {
|
|
191
|
+
minValue: RuleDef<v.ObjectSchema<{
|
|
192
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | v.BooleanSchema<undefined>;
|
|
193
|
+
}, undefined>>;
|
|
194
|
+
maxValue: RuleDef<v.ObjectSchema<{
|
|
195
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | v.BooleanSchema<undefined>;
|
|
196
|
+
}, undefined>>;
|
|
197
|
+
gtValue: RuleDef<v.ObjectSchema<{
|
|
198
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | v.BooleanSchema<undefined>;
|
|
199
|
+
}, undefined>>;
|
|
200
|
+
ltValue: RuleDef<v.ObjectSchema<{
|
|
201
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | v.BooleanSchema<undefined>;
|
|
202
|
+
}, undefined>>;
|
|
203
|
+
value: RuleDef<v.ObjectSchema<{
|
|
204
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | v.BooleanSchema<undefined>;
|
|
205
|
+
}, undefined>>;
|
|
206
|
+
notValue: RuleDef<v.ObjectSchema<{
|
|
207
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | v.BooleanSchema<undefined>;
|
|
208
|
+
}, undefined>>;
|
|
209
|
+
values: RuleDef<v.ObjectSchema<{
|
|
210
|
+
readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined> | v.NumberSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | v.BooleanSchema<undefined>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, "Give at least one value">]>;
|
|
211
|
+
}, undefined>>;
|
|
212
|
+
notValues: RuleDef<v.ObjectSchema<{
|
|
213
|
+
readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined> | v.NumberSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | v.BooleanSchema<undefined>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, "Give at least one value">]>;
|
|
214
|
+
}, undefined>>;
|
|
215
|
+
};
|
|
216
|
+
export declare const contentRules: {
|
|
217
|
+
regex: RuleDef<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
218
|
+
readonly pattern: v.StringSchema<undefined>;
|
|
219
|
+
readonly flags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Flags can be d, g, i, m, s, u, v and y">]>, undefined>;
|
|
220
|
+
}, undefined>, v.BaseValidation<{
|
|
221
|
+
pattern: string;
|
|
222
|
+
flags?: string | undefined;
|
|
223
|
+
}, {
|
|
224
|
+
pattern: string;
|
|
225
|
+
flags?: string | undefined;
|
|
226
|
+
}, v.CheckIssue<{
|
|
227
|
+
pattern: string;
|
|
228
|
+
flags?: string | undefined;
|
|
229
|
+
}>>]>>;
|
|
230
|
+
startsWith: RuleDef<v.ObjectSchema<{
|
|
231
|
+
readonly value: v.StringSchema<undefined>;
|
|
232
|
+
}, undefined>>;
|
|
233
|
+
endsWith: RuleDef<v.ObjectSchema<{
|
|
234
|
+
readonly value: v.StringSchema<undefined>;
|
|
235
|
+
}, undefined>>;
|
|
236
|
+
includes: RuleDef<v.ObjectSchema<{
|
|
237
|
+
readonly value: v.StringSchema<undefined> | v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>;
|
|
238
|
+
}, undefined>>;
|
|
239
|
+
excludes: RuleDef<v.ObjectSchema<{
|
|
240
|
+
readonly value: v.StringSchema<undefined> | v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>;
|
|
241
|
+
}, undefined>>;
|
|
242
|
+
};
|
|
243
|
+
export declare const dateRules: {
|
|
244
|
+
isoDate: RuleDef<AnyObjectSchema>;
|
|
245
|
+
isoDateTime: RuleDef<AnyObjectSchema>;
|
|
246
|
+
isoTime: RuleDef<AnyObjectSchema>;
|
|
247
|
+
isoTimeSecond: RuleDef<AnyObjectSchema>;
|
|
248
|
+
isoTimestamp: RuleDef<AnyObjectSchema>;
|
|
249
|
+
isoWeek: RuleDef<AnyObjectSchema>;
|
|
250
|
+
};
|
|
251
|
+
/** Every built-in rule. Register single families with `includeDefaultRules: false`. */
|
|
174
252
|
export declare const defaultRules: {
|
|
175
253
|
trim: RuleDef<AnyObjectSchema>;
|
|
176
|
-
|
|
254
|
+
trimStart: RuleDef<AnyObjectSchema>;
|
|
255
|
+
trimEnd: RuleDef<AnyObjectSchema>;
|
|
256
|
+
toLowerCase: RuleDef<AnyObjectSchema>;
|
|
257
|
+
toUpperCase: RuleDef<AnyObjectSchema>;
|
|
258
|
+
normalize: RuleDef<import("valibot").ObjectSchema<{
|
|
259
|
+
readonly form: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["NFC", "NFD", "NFKC", "NFKD"], undefined>, undefined>;
|
|
260
|
+
}, undefined>>;
|
|
261
|
+
toMinValue: RuleDef<import("valibot").ObjectSchema<{
|
|
262
|
+
readonly value: import("valibot").NumberSchema<undefined>;
|
|
263
|
+
}, undefined>>;
|
|
264
|
+
toMaxValue: RuleDef<import("valibot").ObjectSchema<{
|
|
265
|
+
readonly value: import("valibot").NumberSchema<undefined>;
|
|
266
|
+
}, undefined>>;
|
|
267
|
+
minSize: RuleDef<import("valibot").ObjectSchema<{
|
|
268
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
269
|
+
}, undefined>>;
|
|
270
|
+
maxSize: RuleDef<import("valibot").ObjectSchema<{
|
|
271
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
272
|
+
}, undefined>>;
|
|
273
|
+
size: RuleDef<import("valibot").ObjectSchema<{
|
|
274
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
275
|
+
}, undefined>>;
|
|
276
|
+
notSize: RuleDef<import("valibot").ObjectSchema<{
|
|
277
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
278
|
+
}, undefined>>;
|
|
279
|
+
mimeType: RuleDef<import("valibot").ObjectSchema<{
|
|
280
|
+
readonly types: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, "Use a MIME type, such as image/png">]>, undefined>, import("valibot").MinLengthAction<string[], 1, "Give at least one MIME type">]>;
|
|
281
|
+
}, undefined>>;
|
|
282
|
+
integer: RuleDef<AnyObjectSchema>;
|
|
283
|
+
safeInteger: RuleDef<AnyObjectSchema>;
|
|
284
|
+
finite: RuleDef<AnyObjectSchema>;
|
|
285
|
+
multipleOf: RuleDef<import("valibot").ObjectSchema<{
|
|
286
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").FiniteAction<number, undefined>, import("valibot").NotValueAction<number, 0, "Can't be 0">]>;
|
|
287
|
+
}, undefined>>;
|
|
288
|
+
minValue: RuleDef<import("valibot").ObjectSchema<{
|
|
289
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | import("valibot").BooleanSchema<undefined>;
|
|
290
|
+
}, undefined>>;
|
|
291
|
+
maxValue: RuleDef<import("valibot").ObjectSchema<{
|
|
292
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | import("valibot").BooleanSchema<undefined>;
|
|
293
|
+
}, undefined>>;
|
|
294
|
+
gtValue: RuleDef<import("valibot").ObjectSchema<{
|
|
295
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | import("valibot").BooleanSchema<undefined>;
|
|
296
|
+
}, undefined>>;
|
|
297
|
+
ltValue: RuleDef<import("valibot").ObjectSchema<{
|
|
298
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | import("valibot").BooleanSchema<undefined>;
|
|
299
|
+
}, undefined>>;
|
|
300
|
+
value: RuleDef<import("valibot").ObjectSchema<{
|
|
301
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | import("valibot").BooleanSchema<undefined>;
|
|
302
|
+
}, undefined>>;
|
|
303
|
+
notValue: RuleDef<import("valibot").ObjectSchema<{
|
|
304
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | import("valibot").BooleanSchema<undefined>;
|
|
305
|
+
}, undefined>>;
|
|
306
|
+
values: RuleDef<import("valibot").ObjectSchema<{
|
|
307
|
+
readonly values: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | import("valibot").BooleanSchema<undefined>, undefined>, import("valibot").MinLengthAction<(string | number | boolean)[], 1, "Give at least one value">]>;
|
|
308
|
+
}, undefined>>;
|
|
309
|
+
notValues: RuleDef<import("valibot").ObjectSchema<{
|
|
310
|
+
readonly values: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]> | import("valibot").BooleanSchema<undefined>, undefined>, import("valibot").MinLengthAction<(string | number | boolean)[], 1, "Give at least one value">]>;
|
|
311
|
+
}, undefined>>;
|
|
312
|
+
isoDate: RuleDef<AnyObjectSchema>;
|
|
313
|
+
isoDateTime: RuleDef<AnyObjectSchema>;
|
|
314
|
+
isoTime: RuleDef<AnyObjectSchema>;
|
|
315
|
+
isoTimeSecond: RuleDef<AnyObjectSchema>;
|
|
316
|
+
isoTimestamp: RuleDef<AnyObjectSchema>;
|
|
317
|
+
isoWeek: RuleDef<AnyObjectSchema>;
|
|
318
|
+
email: RuleDef<AnyObjectSchema>;
|
|
319
|
+
rfcEmail: RuleDef<AnyObjectSchema>;
|
|
320
|
+
url: RuleDef<AnyObjectSchema>;
|
|
321
|
+
domain: RuleDef<AnyObjectSchema>;
|
|
322
|
+
slug: RuleDef<AnyObjectSchema>;
|
|
323
|
+
uuid: RuleDef<AnyObjectSchema>;
|
|
324
|
+
ulid: RuleDef<AnyObjectSchema>;
|
|
325
|
+
cuid2: RuleDef<AnyObjectSchema>;
|
|
326
|
+
nanoid: RuleDef<AnyObjectSchema>;
|
|
327
|
+
ip: RuleDef<AnyObjectSchema>;
|
|
328
|
+
ipv4: RuleDef<AnyObjectSchema>;
|
|
329
|
+
ipv6: RuleDef<AnyObjectSchema>;
|
|
330
|
+
mac: RuleDef<AnyObjectSchema>;
|
|
331
|
+
mac48: RuleDef<AnyObjectSchema>;
|
|
332
|
+
mac64: RuleDef<AnyObjectSchema>;
|
|
333
|
+
hexColor: RuleDef<AnyObjectSchema>;
|
|
334
|
+
hexadecimal: RuleDef<AnyObjectSchema>;
|
|
335
|
+
octal: RuleDef<AnyObjectSchema>;
|
|
336
|
+
decimal: RuleDef<AnyObjectSchema>;
|
|
337
|
+
digits: RuleDef<AnyObjectSchema>;
|
|
338
|
+
base64: RuleDef<AnyObjectSchema>;
|
|
339
|
+
bic: RuleDef<AnyObjectSchema>;
|
|
340
|
+
creditCard: RuleDef<AnyObjectSchema>;
|
|
341
|
+
imei: RuleDef<AnyObjectSchema>;
|
|
342
|
+
isbn: RuleDef<AnyObjectSchema>;
|
|
343
|
+
isrc: RuleDef<AnyObjectSchema>;
|
|
344
|
+
emoji: RuleDef<AnyObjectSchema>;
|
|
345
|
+
hash: RuleDef<import("valibot").ObjectSchema<{
|
|
346
|
+
readonly types: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").PicklistSchema<readonly ["md4", "md5", "sha1", "sha256", "sha384", "sha512", "ripemd128", "ripemd160", "tiger128", "tiger160", "tiger192", "crc32", "crc32b", "adler32"], undefined>, undefined>, import("valibot").MinLengthAction<("md4" | "md5" | "sha1" | "sha256" | "sha384" | "sha512" | "ripemd128" | "ripemd160" | "tiger128" | "tiger160" | "tiger192" | "crc32" | "crc32b" | "adler32")[], 1, "Pick at least one hash type">]>;
|
|
347
|
+
}, undefined>>;
|
|
348
|
+
regex: RuleDef<import("valibot").SchemaWithPipe<readonly [import("valibot").ObjectSchema<{
|
|
349
|
+
readonly pattern: import("valibot").StringSchema<undefined>;
|
|
350
|
+
readonly flags: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, "Flags can be d, g, i, m, s, u, v and y">]>, undefined>;
|
|
351
|
+
}, undefined>, import("valibot").BaseValidation<{
|
|
352
|
+
pattern: string;
|
|
353
|
+
flags?: string | undefined;
|
|
354
|
+
}, {
|
|
355
|
+
pattern: string;
|
|
356
|
+
flags?: string | undefined;
|
|
357
|
+
}, import("valibot").CheckIssue<{
|
|
358
|
+
pattern: string;
|
|
359
|
+
flags?: string | undefined;
|
|
360
|
+
}>>]>>;
|
|
361
|
+
startsWith: RuleDef<import("valibot").ObjectSchema<{
|
|
362
|
+
readonly value: import("valibot").StringSchema<undefined>;
|
|
363
|
+
}, undefined>>;
|
|
364
|
+
endsWith: RuleDef<import("valibot").ObjectSchema<{
|
|
365
|
+
readonly value: import("valibot").StringSchema<undefined>;
|
|
366
|
+
}, undefined>>;
|
|
367
|
+
includes: RuleDef<import("valibot").ObjectSchema<{
|
|
368
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").NumberSchema<undefined>, import("valibot").BooleanSchema<undefined>], undefined>;
|
|
369
|
+
}, undefined>>;
|
|
370
|
+
excludes: RuleDef<import("valibot").ObjectSchema<{
|
|
371
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").NumberSchema<undefined>, import("valibot").BooleanSchema<undefined>], undefined>;
|
|
372
|
+
}, undefined>>;
|
|
373
|
+
graphemes: RuleDef<import("valibot").ObjectSchema<{
|
|
374
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
375
|
+
}, undefined>>;
|
|
376
|
+
minGraphemes: RuleDef<import("valibot").ObjectSchema<{
|
|
377
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
378
|
+
}, undefined>>;
|
|
379
|
+
maxGraphemes: RuleDef<import("valibot").ObjectSchema<{
|
|
380
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
381
|
+
}, undefined>>;
|
|
382
|
+
notGraphemes: RuleDef<import("valibot").ObjectSchema<{
|
|
383
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
384
|
+
}, undefined>>;
|
|
385
|
+
words: RuleDef<import("valibot").ObjectSchema<{
|
|
386
|
+
readonly locale: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
387
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
388
|
+
}, undefined>>;
|
|
389
|
+
minWords: RuleDef<import("valibot").ObjectSchema<{
|
|
390
|
+
readonly locale: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
391
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
392
|
+
}, undefined>>;
|
|
393
|
+
maxWords: RuleDef<import("valibot").ObjectSchema<{
|
|
394
|
+
readonly locale: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
395
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
396
|
+
}, undefined>>;
|
|
397
|
+
notWords: RuleDef<import("valibot").ObjectSchema<{
|
|
398
|
+
readonly locale: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
399
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
400
|
+
}, undefined>>;
|
|
401
|
+
bytes: RuleDef<import("valibot").ObjectSchema<{
|
|
402
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
403
|
+
}, undefined>>;
|
|
404
|
+
minBytes: RuleDef<import("valibot").ObjectSchema<{
|
|
405
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
406
|
+
}, undefined>>;
|
|
407
|
+
maxBytes: RuleDef<import("valibot").ObjectSchema<{
|
|
408
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
409
|
+
}, undefined>>;
|
|
410
|
+
notBytes: RuleDef<import("valibot").ObjectSchema<{
|
|
411
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
412
|
+
}, undefined>>;
|
|
413
|
+
length: RuleDef<import("valibot").ObjectSchema<{
|
|
414
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
415
|
+
}, undefined>>;
|
|
416
|
+
minLength: RuleDef<import("valibot").ObjectSchema<{
|
|
417
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
418
|
+
}, undefined>>;
|
|
419
|
+
maxLength: RuleDef<import("valibot").ObjectSchema<{
|
|
420
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
421
|
+
}, undefined>>;
|
|
422
|
+
notLength: RuleDef<import("valibot").ObjectSchema<{
|
|
423
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
424
|
+
}, undefined>>;
|
|
425
|
+
};
|
|
426
|
+
export declare const defineRule: <T extends AnyObjectSchema>(def: RuleDef<T>) => RuleDef<T>;
|
|
427
|
+
/** Size and type of a File or Blob. */
|
|
428
|
+
export declare const fileRules: {
|
|
429
|
+
minSize: RuleDef<v.ObjectSchema<{
|
|
177
430
|
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
178
431
|
}, undefined>>;
|
|
179
|
-
|
|
432
|
+
maxSize: RuleDef<v.ObjectSchema<{
|
|
180
433
|
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
181
434
|
}, undefined>>;
|
|
182
|
-
|
|
183
|
-
readonly
|
|
184
|
-
|
|
435
|
+
size: RuleDef<v.ObjectSchema<{
|
|
436
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
437
|
+
}, undefined>>;
|
|
438
|
+
notSize: RuleDef<v.ObjectSchema<{
|
|
439
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
440
|
+
}, undefined>>;
|
|
441
|
+
mimeType: RuleDef<v.ObjectSchema<{
|
|
442
|
+
readonly types: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Use a MIME type, such as image/png">]>, undefined>, v.MinLengthAction<string[], 1, "Give at least one MIME type">]>;
|
|
185
443
|
}, undefined>>;
|
|
444
|
+
};
|
|
445
|
+
/** Formats Valibot can check on a string. */
|
|
446
|
+
export declare const formatRules: {
|
|
186
447
|
email: RuleDef<AnyObjectSchema>;
|
|
448
|
+
rfcEmail: RuleDef<AnyObjectSchema>;
|
|
187
449
|
url: RuleDef<AnyObjectSchema>;
|
|
188
|
-
|
|
450
|
+
domain: RuleDef<AnyObjectSchema>;
|
|
451
|
+
slug: RuleDef<AnyObjectSchema>;
|
|
452
|
+
uuid: RuleDef<AnyObjectSchema>;
|
|
453
|
+
ulid: RuleDef<AnyObjectSchema>;
|
|
454
|
+
cuid2: RuleDef<AnyObjectSchema>;
|
|
455
|
+
nanoid: RuleDef<AnyObjectSchema>;
|
|
456
|
+
ip: RuleDef<AnyObjectSchema>;
|
|
457
|
+
ipv4: RuleDef<AnyObjectSchema>;
|
|
458
|
+
ipv6: RuleDef<AnyObjectSchema>;
|
|
459
|
+
mac: RuleDef<AnyObjectSchema>;
|
|
460
|
+
mac48: RuleDef<AnyObjectSchema>;
|
|
461
|
+
mac64: RuleDef<AnyObjectSchema>;
|
|
462
|
+
hexColor: RuleDef<AnyObjectSchema>;
|
|
463
|
+
hexadecimal: RuleDef<AnyObjectSchema>;
|
|
464
|
+
octal: RuleDef<AnyObjectSchema>;
|
|
465
|
+
decimal: RuleDef<AnyObjectSchema>;
|
|
466
|
+
digits: RuleDef<AnyObjectSchema>;
|
|
467
|
+
base64: RuleDef<AnyObjectSchema>;
|
|
468
|
+
bic: RuleDef<AnyObjectSchema>;
|
|
469
|
+
creditCard: RuleDef<AnyObjectSchema>;
|
|
470
|
+
imei: RuleDef<AnyObjectSchema>;
|
|
471
|
+
isbn: RuleDef<AnyObjectSchema>;
|
|
472
|
+
isrc: RuleDef<AnyObjectSchema>;
|
|
473
|
+
emoji: RuleDef<AnyObjectSchema>;
|
|
474
|
+
hash: RuleDef<v.ObjectSchema<{
|
|
475
|
+
readonly types: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["md4", "md5", "sha1", "sha256", "sha384", "sha512", "ripemd128", "ripemd160", "tiger128", "tiger160", "tiger192", "crc32", "crc32b", "adler32"], undefined>, undefined>, v.MinLengthAction<("md4" | "md5" | "sha1" | "sha256" | "sha384" | "sha512" | "ripemd128" | "ripemd160" | "tiger128" | "tiger160" | "tiger192" | "crc32" | "crc32b" | "adler32")[], 1, "Pick at least one hash type">]>;
|
|
476
|
+
}, undefined>>;
|
|
477
|
+
};
|
|
478
|
+
/** Characters of a string, or items of an array */
|
|
479
|
+
export declare const lengthRules: {
|
|
480
|
+
length: RuleDef<v.ObjectSchema<{
|
|
481
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
482
|
+
}, undefined>>;
|
|
483
|
+
minLength: RuleDef<v.ObjectSchema<{
|
|
484
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
485
|
+
}, undefined>>;
|
|
486
|
+
maxLength: RuleDef<v.ObjectSchema<{
|
|
487
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
488
|
+
}, undefined>>;
|
|
489
|
+
notLength: RuleDef<v.ObjectSchema<{
|
|
490
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
491
|
+
}, undefined>>;
|
|
492
|
+
};
|
|
493
|
+
/**
|
|
494
|
+
* Rules that change the value instead of checking it. They run before the required check, so
|
|
495
|
+
* `' '` with `trim` is empty. Their `message` is never shown.
|
|
496
|
+
*/
|
|
497
|
+
export declare const normalizeRules: {
|
|
498
|
+
trim: RuleDef<AnyObjectSchema>;
|
|
499
|
+
trimStart: RuleDef<AnyObjectSchema>;
|
|
500
|
+
trimEnd: RuleDef<AnyObjectSchema>;
|
|
501
|
+
toLowerCase: RuleDef<AnyObjectSchema>;
|
|
502
|
+
toUpperCase: RuleDef<AnyObjectSchema>;
|
|
503
|
+
normalize: RuleDef<v.ObjectSchema<{
|
|
504
|
+
readonly form: v.OptionalSchema<v.PicklistSchema<["NFC", "NFD", "NFKC", "NFKD"], undefined>, undefined>;
|
|
505
|
+
}, undefined>>;
|
|
506
|
+
toMinValue: RuleDef<v.ObjectSchema<{
|
|
189
507
|
readonly value: v.NumberSchema<undefined>;
|
|
190
508
|
}, undefined>>;
|
|
191
|
-
|
|
509
|
+
toMaxValue: RuleDef<v.ObjectSchema<{
|
|
192
510
|
readonly value: v.NumberSchema<undefined>;
|
|
193
511
|
}, undefined>>;
|
|
512
|
+
};
|
|
513
|
+
/** Checks only numbers have. */
|
|
514
|
+
export declare const numberRules: {
|
|
194
515
|
integer: RuleDef<AnyObjectSchema>;
|
|
516
|
+
safeInteger: RuleDef<AnyObjectSchema>;
|
|
517
|
+
finite: RuleDef<AnyObjectSchema>;
|
|
518
|
+
multipleOf: RuleDef<v.ObjectSchema<{
|
|
519
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>, v.NotValueAction<number, 0, "Can't be 0">]>;
|
|
520
|
+
}, undefined>>;
|
|
521
|
+
};
|
|
522
|
+
export declare const textUnitRules: {
|
|
523
|
+
graphemes: RuleDef<v.ObjectSchema<{
|
|
524
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
525
|
+
}, undefined>>;
|
|
526
|
+
minGraphemes: RuleDef<v.ObjectSchema<{
|
|
527
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
528
|
+
}, undefined>>;
|
|
529
|
+
maxGraphemes: RuleDef<v.ObjectSchema<{
|
|
530
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
531
|
+
}, undefined>>;
|
|
532
|
+
notGraphemes: RuleDef<v.ObjectSchema<{
|
|
533
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
534
|
+
}, undefined>>;
|
|
535
|
+
words: RuleDef<v.ObjectSchema<{
|
|
536
|
+
readonly locale: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
537
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
538
|
+
}, undefined>>;
|
|
539
|
+
minWords: RuleDef<v.ObjectSchema<{
|
|
540
|
+
readonly locale: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
541
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
542
|
+
}, undefined>>;
|
|
543
|
+
maxWords: RuleDef<v.ObjectSchema<{
|
|
544
|
+
readonly locale: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
545
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
546
|
+
}, undefined>>;
|
|
547
|
+
notWords: RuleDef<v.ObjectSchema<{
|
|
548
|
+
readonly locale: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
549
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
550
|
+
}, undefined>>;
|
|
551
|
+
bytes: RuleDef<v.ObjectSchema<{
|
|
552
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
553
|
+
}, undefined>>;
|
|
554
|
+
minBytes: RuleDef<v.ObjectSchema<{
|
|
555
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
556
|
+
}, undefined>>;
|
|
557
|
+
maxBytes: RuleDef<v.ObjectSchema<{
|
|
558
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
559
|
+
}, undefined>>;
|
|
560
|
+
notBytes: RuleDef<v.ObjectSchema<{
|
|
561
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
562
|
+
}, undefined>>;
|
|
195
563
|
};
|
|
196
|
-
export declare const defineRule: <T extends AnyObjectSchema>(def: RuleDef<T>) => RuleDef<T>;
|
|
197
564
|
/**
|
|
198
565
|
* Field keys this package owns. A field type's props can't use them.
|
|
199
566
|
*/
|
|
@@ -202,5 +569,5 @@ export declare const RESERVED_FIELD_KEYS: readonly ["name", "type", "label", "de
|
|
|
202
569
|
* Rule keys this package own. A rule's params can't use them.
|
|
203
570
|
*/
|
|
204
571
|
export declare const RESERVED_RULE_KEYS: readonly ["rule", "message"];
|
|
205
|
-
export type { AnyAction, AnyObjectSchema, AnySchema, BuildContext, DefinitionIssue, DefinitionIssueCode, DefinitionPath, FieldTypeDef, FieldWithProps, JsonField, JsonForm, JsonRule, KindDef, MessageContext, RuleDef, RuleStage, SchemaBuilderOptions, ValidateResult, ValueKind };
|
|
572
|
+
export type { AnyAction, AnyObjectSchema, AnySchema, BuildContext, DefinitionIssue, DefinitionIssueCode, DefinitionPath, FieldTypeDef, FieldWithProps, JsonField, JsonForm, JsonRule, KindDef, MessageContext, RuleCategory, RuleDef, RuleMeta, RuleStage, SchemaBuilderOptions, ValidateResult, ValueKind };
|
|
206
573
|
//# sourceMappingURL=index.d.ts.map
|