@whatsaaaa/form-builder-schema 0.2.0 → 0.4.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 +103 -8
- package/dist/index.d.ts +497 -18
- package/dist/index.js +745 -68
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -63,7 +63,16 @@ export declare class DefinitionError extends Error {
|
|
|
63
63
|
constructor(issues: readonly DefinitionIssue[]);
|
|
64
64
|
}
|
|
65
65
|
interface FieldTypeDef<TProps extends AnyObjectSchema = AnyObjectSchema> {
|
|
66
|
-
|
|
66
|
+
/**
|
|
67
|
+
* The kind of the field's value. A function gets the field with its props parsed, for types
|
|
68
|
+
* whose value depends on them: a select with number options has kind `'number'`.
|
|
69
|
+
*/
|
|
70
|
+
kind: ValueKind | KindOf<TProps>;
|
|
71
|
+
/**
|
|
72
|
+
* The kind of each item when the field's kind is `'array'`. A rule that supports this kind but
|
|
73
|
+
* not `'array'` then runs once per item, so `maxSize` works on a multi-file field.
|
|
74
|
+
*/
|
|
75
|
+
itemKind?: ValueKind | KindOf<TProps>;
|
|
67
76
|
/** Extra keys this type accepts on a field, e.g. `options` on a select. */
|
|
68
77
|
props?: TProps;
|
|
69
78
|
/**
|
|
@@ -73,7 +82,20 @@ interface FieldTypeDef<TProps extends AnyObjectSchema = AnyObjectSchema> {
|
|
|
73
82
|
schema?(field: FieldWithProps<TProps>, ctx: BuildContext): AnySchema;
|
|
74
83
|
/** Rules every field of this type gets. A field rule with the same name replaces one. */
|
|
75
84
|
defaultRules?: readonly JsonRule[];
|
|
85
|
+
/**
|
|
86
|
+
* Replaces the kind's required check. A required yes/no radio has kind `'boolean'`, but must
|
|
87
|
+
* accept `false`, so its type returns null here.
|
|
88
|
+
*/
|
|
89
|
+
required?(message: string): AnyAction | null;
|
|
90
|
+
/** Runs last, after every rule, e.g. to turn an ISO string into a `Date`. */
|
|
91
|
+
finalize?(field: FieldWithProps<TProps>): AnyAction | undefined;
|
|
76
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Picks the kind from the field. Declared as a method so it stays bivariant, like `schema()`.
|
|
95
|
+
*/
|
|
96
|
+
type KindOf<TProps extends AnyObjectSchema = AnyObjectSchema> = {
|
|
97
|
+
bivariant(field: FieldWithProps<TProps>): ValueKind;
|
|
98
|
+
}['bivariant'];
|
|
77
99
|
/** A field with its type's props parsed and typed. */
|
|
78
100
|
type FieldWithProps<TProps extends AnyObjectSchema = AnyObjectSchema> = JsonField & v.InferOutput<TProps>;
|
|
79
101
|
interface BuildContext {
|
|
@@ -85,13 +107,26 @@ interface BuildContext {
|
|
|
85
107
|
* as empty. `validate` rules run after it.
|
|
86
108
|
*/
|
|
87
109
|
type RuleStage = 'normalize' | 'validate';
|
|
110
|
+
/** Groups rules in the builder app. One per rule family. */
|
|
111
|
+
type RuleCategory = 'length' | 'text' | 'content' | 'format' | 'date' | 'comparison' | 'number' | 'file' | 'normalize';
|
|
112
|
+
/** Describes a rule to people, e.g. in the builder app's rule picker. */
|
|
113
|
+
interface RuleMeta {
|
|
114
|
+
label: string;
|
|
115
|
+
description?: string;
|
|
116
|
+
category: RuleCategory;
|
|
117
|
+
}
|
|
88
118
|
interface RuleDef<TParams extends AnyObjectSchema = AnyObjectSchema> {
|
|
89
119
|
kinds: readonly ValueKind[];
|
|
90
120
|
/** Defaults to `'validate'`. */
|
|
91
121
|
stage?: RuleStage;
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
|
|
122
|
+
/**
|
|
123
|
+
* The params the rule takes. Omit it for rules without params. Unknown params are rejected.
|
|
124
|
+
* A function gets the field's kind, for params that depend on it (`minValue` takes a number
|
|
125
|
+
* on a number field, and an ISO string on a date field). It is called once per kind.
|
|
126
|
+
*/
|
|
127
|
+
params?: TParams | ((kind: ValueKind) => TParams);
|
|
128
|
+
meta?: RuleMeta;
|
|
129
|
+
/** Method syntax keeps `create` bivariant, so specific rules fit in a `Record<string, RuleDef>`. */
|
|
95
130
|
create(params: v.InferOutput<TParams>, message?: string): AnyAction;
|
|
96
131
|
}
|
|
97
132
|
interface MessageContext {
|
|
@@ -103,6 +138,7 @@ interface SchemaBuilderOptions {
|
|
|
103
138
|
kinds?: Record<string, KindDef>;
|
|
104
139
|
fieldTypes?: Record<string, FieldTypeDef>;
|
|
105
140
|
rules?: Record<string, RuleDef>;
|
|
141
|
+
includeDefaultRules?: boolean;
|
|
106
142
|
messages?: {
|
|
107
143
|
required?: string;
|
|
108
144
|
};
|
|
@@ -115,29 +151,120 @@ interface SchemaBuilderOptions {
|
|
|
115
151
|
export declare function createSchemaBuilder(options?: SchemaBuilderOptions): {
|
|
116
152
|
build: (json: JsonForm) => v.ObjectSchema<v.ObjectEntries, undefined>;
|
|
117
153
|
validate: (json: unknown) => ValidateResult;
|
|
154
|
+
rulesForKind: (kind: ValueKind) => [name: string, def: RuleDef][];
|
|
118
155
|
kinds: Readonly<Record<string, KindDef>>;
|
|
119
156
|
fieldTypes: Readonly<Record<string, FieldTypeDef<AnyObjectSchema>>>;
|
|
120
157
|
rules: Readonly<Record<string, RuleDef<AnyObjectSchema>>>;
|
|
121
158
|
};
|
|
159
|
+
/** Every built-in field type. */
|
|
122
160
|
export declare const defaultFieldTypes: {
|
|
161
|
+
heading: FieldTypeDef<import("valibot").ObjectSchema<{
|
|
162
|
+
readonly text: import("valibot").StringSchema<undefined>;
|
|
163
|
+
readonly level: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 6, undefined>]>, undefined>;
|
|
164
|
+
}, undefined>>;
|
|
165
|
+
paragraph: FieldTypeDef<import("valibot").ObjectSchema<{
|
|
166
|
+
readonly text: import("valibot").StringSchema<undefined>;
|
|
167
|
+
}, undefined>>;
|
|
168
|
+
divider: {
|
|
169
|
+
kind: "none";
|
|
170
|
+
};
|
|
171
|
+
file: FieldTypeDef<import("valibot").ObjectSchema<{
|
|
172
|
+
readonly multiple: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
|
|
173
|
+
readonly accept: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "Use MIME types separated by commas, such as image/png,image/jpeg">]>, undefined>;
|
|
174
|
+
}, undefined>>;
|
|
175
|
+
select: FieldTypeDef<import("valibot").ObjectSchema<{
|
|
176
|
+
readonly options: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").ObjectSchema<{
|
|
177
|
+
readonly value: import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").NumberSchema<undefined>], undefined>;
|
|
178
|
+
readonly label: import("valibot").StringSchema<undefined>;
|
|
179
|
+
}, undefined>, undefined>, import("valibot").MinLengthAction<{
|
|
180
|
+
value: string | number;
|
|
181
|
+
label: string;
|
|
182
|
+
}[], 1, "Give at least one option">, import("valibot").CheckAction<{
|
|
183
|
+
value: string | number;
|
|
184
|
+
label: string;
|
|
185
|
+
}[], "Give every option a value of the same type">, import("valibot").CheckAction<{
|
|
186
|
+
value: string | number;
|
|
187
|
+
label: string;
|
|
188
|
+
}[], "Give every option a different value">]>, undefined>;
|
|
189
|
+
readonly valueType: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["string", "number"], undefined>, undefined>;
|
|
190
|
+
}, undefined>>;
|
|
191
|
+
radio: FieldTypeDef<import("valibot").ObjectSchema<{
|
|
192
|
+
readonly options: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").ObjectSchema<{
|
|
193
|
+
readonly value: import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").NumberSchema<undefined>, import("valibot").BooleanSchema<undefined>], undefined>;
|
|
194
|
+
readonly label: import("valibot").StringSchema<undefined>;
|
|
195
|
+
}, undefined>, undefined>, import("valibot").MinLengthAction<{
|
|
196
|
+
value: string | number | boolean;
|
|
197
|
+
label: string;
|
|
198
|
+
}[], 1, "Give at least one option">, import("valibot").CheckAction<{
|
|
199
|
+
value: string | number | boolean;
|
|
200
|
+
label: string;
|
|
201
|
+
}[], "Give every option a value of the same type">, import("valibot").CheckAction<{
|
|
202
|
+
value: string | number | boolean;
|
|
203
|
+
label: string;
|
|
204
|
+
}[], "Give every option a different value">]>;
|
|
205
|
+
}, undefined>>;
|
|
206
|
+
multiselect: FieldTypeDef<import("valibot").ObjectSchema<{
|
|
207
|
+
readonly options: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").ObjectSchema<{
|
|
208
|
+
readonly value: import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").NumberSchema<undefined>], undefined>;
|
|
209
|
+
readonly label: import("valibot").StringSchema<undefined>;
|
|
210
|
+
}, undefined>, undefined>, import("valibot").MinLengthAction<{
|
|
211
|
+
value: string | number;
|
|
212
|
+
label: string;
|
|
213
|
+
}[], 1, "Give at least one option">, import("valibot").CheckAction<{
|
|
214
|
+
value: string | number;
|
|
215
|
+
label: string;
|
|
216
|
+
}[], "Give every option a value of the same type">, import("valibot").CheckAction<{
|
|
217
|
+
value: string | number;
|
|
218
|
+
label: string;
|
|
219
|
+
}[], "Give every option a different value">]>;
|
|
220
|
+
}, undefined>>;
|
|
221
|
+
date: FieldTypeDef<import("valibot").ObjectSchema<{
|
|
222
|
+
readonly output: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["string", "date"], undefined>, undefined>;
|
|
223
|
+
}, undefined>>;
|
|
224
|
+
time: {
|
|
225
|
+
kind: "date";
|
|
226
|
+
schema: () => import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").IsoTimeAction<string, undefined>]>;
|
|
227
|
+
};
|
|
228
|
+
datetime: FieldTypeDef<import("valibot").ObjectSchema<{
|
|
229
|
+
readonly output: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["string", "date"], undefined>, undefined>;
|
|
230
|
+
}, undefined>>;
|
|
123
231
|
text: {
|
|
124
232
|
kind: "string";
|
|
125
|
-
schema: () =>
|
|
233
|
+
schema: () => import("valibot").StringSchema<undefined>;
|
|
126
234
|
};
|
|
127
|
-
|
|
235
|
+
textarea: {
|
|
128
236
|
kind: "string";
|
|
129
|
-
schema: () =>
|
|
237
|
+
schema: () => import("valibot").StringSchema<undefined>;
|
|
130
238
|
};
|
|
131
239
|
email: {
|
|
132
240
|
kind: "string";
|
|
133
|
-
schema: () =>
|
|
241
|
+
schema: () => import("valibot").StringSchema<undefined>;
|
|
134
242
|
defaultRules: {
|
|
135
243
|
rule: string;
|
|
136
244
|
}[];
|
|
137
245
|
};
|
|
246
|
+
password: {
|
|
247
|
+
kind: "string";
|
|
248
|
+
schema: () => import("valibot").StringSchema<undefined>;
|
|
249
|
+
};
|
|
250
|
+
url: {
|
|
251
|
+
kind: "string";
|
|
252
|
+
schema: () => import("valibot").StringSchema<undefined>;
|
|
253
|
+
defaultRules: {
|
|
254
|
+
rule: string;
|
|
255
|
+
}[];
|
|
256
|
+
};
|
|
257
|
+
tel: {
|
|
258
|
+
kind: "string";
|
|
259
|
+
schema: () => import("valibot").StringSchema<undefined>;
|
|
260
|
+
};
|
|
138
261
|
number: {
|
|
139
262
|
kind: "number";
|
|
140
|
-
schema: () =>
|
|
263
|
+
schema: () => import("valibot").NumberSchema<undefined>;
|
|
264
|
+
};
|
|
265
|
+
checkbox: {
|
|
266
|
+
kind: "boolean";
|
|
267
|
+
schema: () => import("valibot").BooleanSchema<undefined>;
|
|
141
268
|
};
|
|
142
269
|
};
|
|
143
270
|
export declare const defineFieldType: <T extends AnyObjectSchema>(def: FieldTypeDef<T>) => FieldTypeDef<T>;
|
|
@@ -171,29 +298,381 @@ export declare const defaultKinds: {
|
|
|
171
298
|
isEmpty: () => true;
|
|
172
299
|
};
|
|
173
300
|
};
|
|
301
|
+
/** Compares the value with a param of the same type. */
|
|
302
|
+
export declare const comparisonRules: {
|
|
303
|
+
minValue: RuleDef<v.ObjectSchema<{
|
|
304
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.BooleanSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]>;
|
|
305
|
+
}, undefined>>;
|
|
306
|
+
maxValue: RuleDef<v.ObjectSchema<{
|
|
307
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.BooleanSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]>;
|
|
308
|
+
}, undefined>>;
|
|
309
|
+
gtValue: RuleDef<v.ObjectSchema<{
|
|
310
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.BooleanSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]>;
|
|
311
|
+
}, undefined>>;
|
|
312
|
+
ltValue: RuleDef<v.ObjectSchema<{
|
|
313
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.BooleanSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]>;
|
|
314
|
+
}, undefined>>;
|
|
315
|
+
value: RuleDef<v.ObjectSchema<{
|
|
316
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.BooleanSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]>;
|
|
317
|
+
}, undefined>>;
|
|
318
|
+
notValue: RuleDef<v.ObjectSchema<{
|
|
319
|
+
readonly value: v.StringSchema<undefined> | v.NumberSchema<undefined> | v.BooleanSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]>;
|
|
320
|
+
}, undefined>>;
|
|
321
|
+
values: RuleDef<v.ObjectSchema<{
|
|
322
|
+
readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined> | v.NumberSchema<undefined> | v.BooleanSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, "Give at least one value">]>;
|
|
323
|
+
}, undefined>>;
|
|
324
|
+
notValues: RuleDef<v.ObjectSchema<{
|
|
325
|
+
readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined> | v.NumberSchema<undefined> | v.BooleanSchema<undefined> | v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use an ISO date, date-time or time, such as 2026-01-01">]>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, "Give at least one value">]>;
|
|
326
|
+
}, undefined>>;
|
|
327
|
+
};
|
|
328
|
+
export declare const contentRules: {
|
|
329
|
+
regex: RuleDef<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
330
|
+
readonly pattern: v.StringSchema<undefined>;
|
|
331
|
+
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>;
|
|
332
|
+
}, undefined>, v.BaseValidation<{
|
|
333
|
+
pattern: string;
|
|
334
|
+
flags?: string | undefined;
|
|
335
|
+
}, {
|
|
336
|
+
pattern: string;
|
|
337
|
+
flags?: string | undefined;
|
|
338
|
+
}, v.CheckIssue<{
|
|
339
|
+
pattern: string;
|
|
340
|
+
flags?: string | undefined;
|
|
341
|
+
}>>]>>;
|
|
342
|
+
startsWith: RuleDef<v.ObjectSchema<{
|
|
343
|
+
readonly value: v.StringSchema<undefined>;
|
|
344
|
+
}, undefined>>;
|
|
345
|
+
endsWith: RuleDef<v.ObjectSchema<{
|
|
346
|
+
readonly value: v.StringSchema<undefined>;
|
|
347
|
+
}, undefined>>;
|
|
348
|
+
includes: RuleDef<v.ObjectSchema<{
|
|
349
|
+
readonly value: v.StringSchema<undefined> | v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>;
|
|
350
|
+
}, undefined>>;
|
|
351
|
+
excludes: RuleDef<v.ObjectSchema<{
|
|
352
|
+
readonly value: v.StringSchema<undefined> | v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>;
|
|
353
|
+
}, undefined>>;
|
|
354
|
+
};
|
|
355
|
+
export declare const dateRules: {
|
|
356
|
+
isoDate: RuleDef<AnyObjectSchema>;
|
|
357
|
+
isoDateTime: RuleDef<AnyObjectSchema>;
|
|
358
|
+
isoTime: RuleDef<AnyObjectSchema>;
|
|
359
|
+
isoTimeSecond: RuleDef<AnyObjectSchema>;
|
|
360
|
+
isoTimestamp: RuleDef<AnyObjectSchema>;
|
|
361
|
+
isoWeek: RuleDef<AnyObjectSchema>;
|
|
362
|
+
};
|
|
363
|
+
/** Every built-in rule. Register single families with `includeDefaultRules: false`. */
|
|
174
364
|
export declare const defaultRules: {
|
|
175
365
|
trim: RuleDef<AnyObjectSchema>;
|
|
176
|
-
|
|
366
|
+
trimStart: RuleDef<AnyObjectSchema>;
|
|
367
|
+
trimEnd: RuleDef<AnyObjectSchema>;
|
|
368
|
+
toLowerCase: RuleDef<AnyObjectSchema>;
|
|
369
|
+
toUpperCase: RuleDef<AnyObjectSchema>;
|
|
370
|
+
normalize: RuleDef<import("valibot").ObjectSchema<{
|
|
371
|
+
readonly form: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["NFC", "NFD", "NFKC", "NFKD"], undefined>, undefined>;
|
|
372
|
+
}, undefined>>;
|
|
373
|
+
toMinValue: RuleDef<import("valibot").ObjectSchema<{
|
|
374
|
+
readonly value: import("valibot").NumberSchema<undefined>;
|
|
375
|
+
}, undefined>>;
|
|
376
|
+
toMaxValue: RuleDef<import("valibot").ObjectSchema<{
|
|
377
|
+
readonly value: import("valibot").NumberSchema<undefined>;
|
|
378
|
+
}, undefined>>;
|
|
379
|
+
minSize: 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
|
+
maxSize: 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
|
+
size: RuleDef<import("valibot").ObjectSchema<{
|
|
386
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
387
|
+
}, undefined>>;
|
|
388
|
+
notSize: RuleDef<import("valibot").ObjectSchema<{
|
|
389
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
390
|
+
}, undefined>>;
|
|
391
|
+
mimeType: RuleDef<import("valibot").ObjectSchema<{
|
|
392
|
+
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">]>;
|
|
393
|
+
}, undefined>>;
|
|
394
|
+
integer: RuleDef<AnyObjectSchema>;
|
|
395
|
+
safeInteger: RuleDef<AnyObjectSchema>;
|
|
396
|
+
finite: RuleDef<AnyObjectSchema>;
|
|
397
|
+
multipleOf: RuleDef<import("valibot").ObjectSchema<{
|
|
398
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").FiniteAction<number, undefined>, import("valibot").NotValueAction<number, 0, "Can't be 0">]>;
|
|
399
|
+
}, undefined>>;
|
|
400
|
+
minValue: RuleDef<import("valibot").ObjectSchema<{
|
|
401
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").BooleanSchema<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">]>;
|
|
402
|
+
}, undefined>>;
|
|
403
|
+
maxValue: RuleDef<import("valibot").ObjectSchema<{
|
|
404
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").BooleanSchema<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">]>;
|
|
405
|
+
}, undefined>>;
|
|
406
|
+
gtValue: RuleDef<import("valibot").ObjectSchema<{
|
|
407
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").BooleanSchema<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">]>;
|
|
408
|
+
}, undefined>>;
|
|
409
|
+
ltValue: RuleDef<import("valibot").ObjectSchema<{
|
|
410
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").BooleanSchema<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">]>;
|
|
411
|
+
}, undefined>>;
|
|
412
|
+
value: RuleDef<import("valibot").ObjectSchema<{
|
|
413
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").BooleanSchema<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">]>;
|
|
414
|
+
}, undefined>>;
|
|
415
|
+
notValue: RuleDef<import("valibot").ObjectSchema<{
|
|
416
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").BooleanSchema<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">]>;
|
|
417
|
+
}, undefined>>;
|
|
418
|
+
values: RuleDef<import("valibot").ObjectSchema<{
|
|
419
|
+
readonly values: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").BooleanSchema<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">]>, undefined>, import("valibot").MinLengthAction<(string | number | boolean)[], 1, "Give at least one value">]>;
|
|
420
|
+
}, undefined>>;
|
|
421
|
+
notValues: RuleDef<import("valibot").ObjectSchema<{
|
|
422
|
+
readonly values: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").StringSchema<undefined> | import("valibot").NumberSchema<undefined> | import("valibot").BooleanSchema<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">]>, undefined>, import("valibot").MinLengthAction<(string | number | boolean)[], 1, "Give at least one value">]>;
|
|
423
|
+
}, undefined>>;
|
|
424
|
+
isoDate: RuleDef<AnyObjectSchema>;
|
|
425
|
+
isoDateTime: RuleDef<AnyObjectSchema>;
|
|
426
|
+
isoTime: RuleDef<AnyObjectSchema>;
|
|
427
|
+
isoTimeSecond: RuleDef<AnyObjectSchema>;
|
|
428
|
+
isoTimestamp: RuleDef<AnyObjectSchema>;
|
|
429
|
+
isoWeek: RuleDef<AnyObjectSchema>;
|
|
430
|
+
email: RuleDef<AnyObjectSchema>;
|
|
431
|
+
rfcEmail: RuleDef<AnyObjectSchema>;
|
|
432
|
+
url: RuleDef<AnyObjectSchema>;
|
|
433
|
+
domain: RuleDef<AnyObjectSchema>;
|
|
434
|
+
slug: RuleDef<AnyObjectSchema>;
|
|
435
|
+
uuid: RuleDef<AnyObjectSchema>;
|
|
436
|
+
ulid: RuleDef<AnyObjectSchema>;
|
|
437
|
+
cuid2: RuleDef<AnyObjectSchema>;
|
|
438
|
+
nanoid: RuleDef<AnyObjectSchema>;
|
|
439
|
+
ip: RuleDef<AnyObjectSchema>;
|
|
440
|
+
ipv4: RuleDef<AnyObjectSchema>;
|
|
441
|
+
ipv6: RuleDef<AnyObjectSchema>;
|
|
442
|
+
mac: RuleDef<AnyObjectSchema>;
|
|
443
|
+
mac48: RuleDef<AnyObjectSchema>;
|
|
444
|
+
mac64: RuleDef<AnyObjectSchema>;
|
|
445
|
+
hexColor: RuleDef<AnyObjectSchema>;
|
|
446
|
+
hexadecimal: RuleDef<AnyObjectSchema>;
|
|
447
|
+
octal: RuleDef<AnyObjectSchema>;
|
|
448
|
+
decimal: RuleDef<AnyObjectSchema>;
|
|
449
|
+
digits: RuleDef<AnyObjectSchema>;
|
|
450
|
+
base64: RuleDef<AnyObjectSchema>;
|
|
451
|
+
bic: RuleDef<AnyObjectSchema>;
|
|
452
|
+
creditCard: RuleDef<AnyObjectSchema>;
|
|
453
|
+
imei: RuleDef<AnyObjectSchema>;
|
|
454
|
+
isbn: RuleDef<AnyObjectSchema>;
|
|
455
|
+
isrc: RuleDef<AnyObjectSchema>;
|
|
456
|
+
emoji: RuleDef<AnyObjectSchema>;
|
|
457
|
+
hash: RuleDef<import("valibot").ObjectSchema<{
|
|
458
|
+
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">]>;
|
|
459
|
+
}, undefined>>;
|
|
460
|
+
regex: RuleDef<import("valibot").SchemaWithPipe<readonly [import("valibot").ObjectSchema<{
|
|
461
|
+
readonly pattern: import("valibot").StringSchema<undefined>;
|
|
462
|
+
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>;
|
|
463
|
+
}, undefined>, import("valibot").BaseValidation<{
|
|
464
|
+
pattern: string;
|
|
465
|
+
flags?: string | undefined;
|
|
466
|
+
}, {
|
|
467
|
+
pattern: string;
|
|
468
|
+
flags?: string | undefined;
|
|
469
|
+
}, import("valibot").CheckIssue<{
|
|
470
|
+
pattern: string;
|
|
471
|
+
flags?: string | undefined;
|
|
472
|
+
}>>]>>;
|
|
473
|
+
startsWith: RuleDef<import("valibot").ObjectSchema<{
|
|
474
|
+
readonly value: import("valibot").StringSchema<undefined>;
|
|
475
|
+
}, undefined>>;
|
|
476
|
+
endsWith: RuleDef<import("valibot").ObjectSchema<{
|
|
477
|
+
readonly value: import("valibot").StringSchema<undefined>;
|
|
478
|
+
}, undefined>>;
|
|
479
|
+
includes: RuleDef<import("valibot").ObjectSchema<{
|
|
480
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").NumberSchema<undefined>, import("valibot").BooleanSchema<undefined>], undefined>;
|
|
481
|
+
}, undefined>>;
|
|
482
|
+
excludes: RuleDef<import("valibot").ObjectSchema<{
|
|
483
|
+
readonly value: import("valibot").StringSchema<undefined> | import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").NumberSchema<undefined>, import("valibot").BooleanSchema<undefined>], undefined>;
|
|
484
|
+
}, undefined>>;
|
|
485
|
+
graphemes: RuleDef<import("valibot").ObjectSchema<{
|
|
486
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
487
|
+
}, undefined>>;
|
|
488
|
+
minGraphemes: RuleDef<import("valibot").ObjectSchema<{
|
|
489
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
490
|
+
}, undefined>>;
|
|
491
|
+
maxGraphemes: RuleDef<import("valibot").ObjectSchema<{
|
|
492
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
493
|
+
}, undefined>>;
|
|
494
|
+
notGraphemes: RuleDef<import("valibot").ObjectSchema<{
|
|
495
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
496
|
+
}, undefined>>;
|
|
497
|
+
words: RuleDef<import("valibot").ObjectSchema<{
|
|
498
|
+
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>;
|
|
499
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
500
|
+
}, undefined>>;
|
|
501
|
+
minWords: RuleDef<import("valibot").ObjectSchema<{
|
|
502
|
+
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>;
|
|
503
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
504
|
+
}, undefined>>;
|
|
505
|
+
maxWords: RuleDef<import("valibot").ObjectSchema<{
|
|
506
|
+
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>;
|
|
507
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
508
|
+
}, undefined>>;
|
|
509
|
+
notWords: RuleDef<import("valibot").ObjectSchema<{
|
|
510
|
+
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>;
|
|
511
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
512
|
+
}, undefined>>;
|
|
513
|
+
bytes: RuleDef<import("valibot").ObjectSchema<{
|
|
514
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
515
|
+
}, undefined>>;
|
|
516
|
+
minBytes: RuleDef<import("valibot").ObjectSchema<{
|
|
517
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
518
|
+
}, undefined>>;
|
|
519
|
+
maxBytes: RuleDef<import("valibot").ObjectSchema<{
|
|
520
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
521
|
+
}, undefined>>;
|
|
522
|
+
notBytes: RuleDef<import("valibot").ObjectSchema<{
|
|
523
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
524
|
+
}, undefined>>;
|
|
525
|
+
length: RuleDef<import("valibot").ObjectSchema<{
|
|
526
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
527
|
+
}, undefined>>;
|
|
528
|
+
minLength: RuleDef<import("valibot").ObjectSchema<{
|
|
529
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
530
|
+
}, undefined>>;
|
|
531
|
+
maxLength: RuleDef<import("valibot").ObjectSchema<{
|
|
532
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
533
|
+
}, undefined>>;
|
|
534
|
+
notLength: RuleDef<import("valibot").ObjectSchema<{
|
|
535
|
+
readonly value: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
|
|
536
|
+
}, undefined>>;
|
|
537
|
+
};
|
|
538
|
+
export declare const defineRule: <T extends AnyObjectSchema>(def: RuleDef<T>) => RuleDef<T>;
|
|
539
|
+
/** Size and type of a File or Blob. */
|
|
540
|
+
export declare const fileRules: {
|
|
541
|
+
minSize: RuleDef<v.ObjectSchema<{
|
|
177
542
|
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
178
543
|
}, undefined>>;
|
|
179
|
-
|
|
544
|
+
maxSize: RuleDef<v.ObjectSchema<{
|
|
180
545
|
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
181
546
|
}, undefined>>;
|
|
182
|
-
|
|
183
|
-
readonly
|
|
184
|
-
readonly flags: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
547
|
+
size: RuleDef<v.ObjectSchema<{
|
|
548
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
185
549
|
}, undefined>>;
|
|
550
|
+
notSize: RuleDef<v.ObjectSchema<{
|
|
551
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
552
|
+
}, undefined>>;
|
|
553
|
+
mimeType: RuleDef<v.ObjectSchema<{
|
|
554
|
+
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">]>;
|
|
555
|
+
}, undefined>>;
|
|
556
|
+
};
|
|
557
|
+
/** Formats Valibot can check on a string. */
|
|
558
|
+
export declare const formatRules: {
|
|
186
559
|
email: RuleDef<AnyObjectSchema>;
|
|
560
|
+
rfcEmail: RuleDef<AnyObjectSchema>;
|
|
187
561
|
url: RuleDef<AnyObjectSchema>;
|
|
188
|
-
|
|
562
|
+
domain: RuleDef<AnyObjectSchema>;
|
|
563
|
+
slug: RuleDef<AnyObjectSchema>;
|
|
564
|
+
uuid: RuleDef<AnyObjectSchema>;
|
|
565
|
+
ulid: RuleDef<AnyObjectSchema>;
|
|
566
|
+
cuid2: RuleDef<AnyObjectSchema>;
|
|
567
|
+
nanoid: RuleDef<AnyObjectSchema>;
|
|
568
|
+
ip: RuleDef<AnyObjectSchema>;
|
|
569
|
+
ipv4: RuleDef<AnyObjectSchema>;
|
|
570
|
+
ipv6: RuleDef<AnyObjectSchema>;
|
|
571
|
+
mac: RuleDef<AnyObjectSchema>;
|
|
572
|
+
mac48: RuleDef<AnyObjectSchema>;
|
|
573
|
+
mac64: RuleDef<AnyObjectSchema>;
|
|
574
|
+
hexColor: RuleDef<AnyObjectSchema>;
|
|
575
|
+
hexadecimal: RuleDef<AnyObjectSchema>;
|
|
576
|
+
octal: RuleDef<AnyObjectSchema>;
|
|
577
|
+
decimal: RuleDef<AnyObjectSchema>;
|
|
578
|
+
digits: RuleDef<AnyObjectSchema>;
|
|
579
|
+
base64: RuleDef<AnyObjectSchema>;
|
|
580
|
+
bic: RuleDef<AnyObjectSchema>;
|
|
581
|
+
creditCard: RuleDef<AnyObjectSchema>;
|
|
582
|
+
imei: RuleDef<AnyObjectSchema>;
|
|
583
|
+
isbn: RuleDef<AnyObjectSchema>;
|
|
584
|
+
isrc: RuleDef<AnyObjectSchema>;
|
|
585
|
+
emoji: RuleDef<AnyObjectSchema>;
|
|
586
|
+
hash: RuleDef<v.ObjectSchema<{
|
|
587
|
+
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">]>;
|
|
588
|
+
}, undefined>>;
|
|
589
|
+
};
|
|
590
|
+
/** Characters of a string, or items of an array */
|
|
591
|
+
export declare const lengthRules: {
|
|
592
|
+
length: RuleDef<v.ObjectSchema<{
|
|
593
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
594
|
+
}, undefined>>;
|
|
595
|
+
minLength: RuleDef<v.ObjectSchema<{
|
|
596
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
597
|
+
}, undefined>>;
|
|
598
|
+
maxLength: RuleDef<v.ObjectSchema<{
|
|
599
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
600
|
+
}, undefined>>;
|
|
601
|
+
notLength: RuleDef<v.ObjectSchema<{
|
|
602
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
603
|
+
}, undefined>>;
|
|
604
|
+
};
|
|
605
|
+
/**
|
|
606
|
+
* Rules that change the value instead of checking it. They run before the required check, so
|
|
607
|
+
* `' '` with `trim` is empty. Their `message` is never shown.
|
|
608
|
+
*/
|
|
609
|
+
export declare const normalizeRules: {
|
|
610
|
+
trim: RuleDef<AnyObjectSchema>;
|
|
611
|
+
trimStart: RuleDef<AnyObjectSchema>;
|
|
612
|
+
trimEnd: RuleDef<AnyObjectSchema>;
|
|
613
|
+
toLowerCase: RuleDef<AnyObjectSchema>;
|
|
614
|
+
toUpperCase: RuleDef<AnyObjectSchema>;
|
|
615
|
+
normalize: RuleDef<v.ObjectSchema<{
|
|
616
|
+
readonly form: v.OptionalSchema<v.PicklistSchema<["NFC", "NFD", "NFKC", "NFKD"], undefined>, undefined>;
|
|
617
|
+
}, undefined>>;
|
|
618
|
+
toMinValue: RuleDef<v.ObjectSchema<{
|
|
189
619
|
readonly value: v.NumberSchema<undefined>;
|
|
190
620
|
}, undefined>>;
|
|
191
|
-
|
|
621
|
+
toMaxValue: RuleDef<v.ObjectSchema<{
|
|
192
622
|
readonly value: v.NumberSchema<undefined>;
|
|
193
623
|
}, undefined>>;
|
|
624
|
+
};
|
|
625
|
+
/** Checks only numbers have. */
|
|
626
|
+
export declare const numberRules: {
|
|
194
627
|
integer: RuleDef<AnyObjectSchema>;
|
|
628
|
+
safeInteger: RuleDef<AnyObjectSchema>;
|
|
629
|
+
finite: RuleDef<AnyObjectSchema>;
|
|
630
|
+
multipleOf: RuleDef<v.ObjectSchema<{
|
|
631
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>, v.NotValueAction<number, 0, "Can't be 0">]>;
|
|
632
|
+
}, undefined>>;
|
|
633
|
+
};
|
|
634
|
+
export declare const textUnitRules: {
|
|
635
|
+
graphemes: RuleDef<v.ObjectSchema<{
|
|
636
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
637
|
+
}, undefined>>;
|
|
638
|
+
minGraphemes: RuleDef<v.ObjectSchema<{
|
|
639
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
640
|
+
}, undefined>>;
|
|
641
|
+
maxGraphemes: RuleDef<v.ObjectSchema<{
|
|
642
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
643
|
+
}, undefined>>;
|
|
644
|
+
notGraphemes: RuleDef<v.ObjectSchema<{
|
|
645
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
646
|
+
}, undefined>>;
|
|
647
|
+
words: RuleDef<v.ObjectSchema<{
|
|
648
|
+
readonly locale: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
649
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
650
|
+
}, undefined>>;
|
|
651
|
+
minWords: RuleDef<v.ObjectSchema<{
|
|
652
|
+
readonly locale: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
653
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
654
|
+
}, undefined>>;
|
|
655
|
+
maxWords: RuleDef<v.ObjectSchema<{
|
|
656
|
+
readonly locale: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
657
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
658
|
+
}, undefined>>;
|
|
659
|
+
notWords: RuleDef<v.ObjectSchema<{
|
|
660
|
+
readonly locale: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use a language tag, such as en or sr-Latn">]>, undefined>;
|
|
661
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
662
|
+
}, undefined>>;
|
|
663
|
+
bytes: RuleDef<v.ObjectSchema<{
|
|
664
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
665
|
+
}, undefined>>;
|
|
666
|
+
minBytes: RuleDef<v.ObjectSchema<{
|
|
667
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
668
|
+
}, undefined>>;
|
|
669
|
+
maxBytes: RuleDef<v.ObjectSchema<{
|
|
670
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
671
|
+
}, undefined>>;
|
|
672
|
+
notBytes: RuleDef<v.ObjectSchema<{
|
|
673
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
674
|
+
}, undefined>>;
|
|
195
675
|
};
|
|
196
|
-
export declare const defineRule: <T extends AnyObjectSchema>(def: RuleDef<T>) => RuleDef<T>;
|
|
197
676
|
/**
|
|
198
677
|
* Field keys this package owns. A field type's props can't use them.
|
|
199
678
|
*/
|
|
@@ -202,5 +681,5 @@ export declare const RESERVED_FIELD_KEYS: readonly ["name", "type", "label", "de
|
|
|
202
681
|
* Rule keys this package own. A rule's params can't use them.
|
|
203
682
|
*/
|
|
204
683
|
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 };
|
|
684
|
+
export type { AnyAction, AnyObjectSchema, AnySchema, BuildContext, DefinitionIssue, DefinitionIssueCode, DefinitionPath, FieldTypeDef, FieldWithProps, JsonField, JsonForm, JsonRule, KindDef, KindOf, MessageContext, RuleCategory, RuleDef, RuleMeta, RuleStage, SchemaBuilderOptions, ValidateResult, ValueKind };
|
|
206
685
|
//# sourceMappingURL=index.d.ts.map
|