unischema 1.0.0 → 1.1.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 +634 -230
- package/dist/adapters/backend/index.d.mts +2 -1
- package/dist/adapters/backend/index.d.ts +2 -1
- package/dist/adapters/backend/index.js +17 -423
- package/dist/adapters/backend/index.mjs +9 -415
- package/dist/adapters/frontend/index.d.mts +2 -1
- package/dist/adapters/frontend/index.d.ts +2 -1
- package/dist/adapters/frontend/index.js +10 -403
- package/dist/adapters/frontend/index.mjs +8 -401
- package/dist/chunk-2JYFKT3R.js +103 -0
- package/dist/chunk-3FANCMEF.js +206 -0
- package/dist/chunk-3TS35CVJ.mjs +478 -0
- package/dist/chunk-ASKTY6EG.js +131 -0
- package/dist/chunk-BJLVOIAP.js +491 -0
- package/dist/chunk-BNIB23NQ.js +90 -0
- package/dist/chunk-BVRXGZLS.js +17 -0
- package/dist/chunk-CQYXR2LZ.js +353 -0
- package/dist/chunk-ELL7U7IC.mjs +237 -0
- package/dist/chunk-FKDWSZIV.mjs +39 -0
- package/dist/chunk-FRBZHN4K.mjs +335 -0
- package/dist/chunk-FZ7K2PC7.js +248 -0
- package/dist/chunk-KHHJD6QK.mjs +85 -0
- package/dist/chunk-NUW55QTO.js +48 -0
- package/dist/chunk-TTK77YBI.mjs +15 -0
- package/dist/chunk-VWP24NYS.mjs +194 -0
- package/dist/chunk-XC4DKEXP.mjs +97 -0
- package/dist/chunk-XGTUU27F.mjs +124 -0
- package/dist/index-BQR7OrY7.d.mts +80 -0
- package/dist/index-BQR7OrY7.d.ts +80 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +537 -476
- package/dist/index.mjs +486 -464
- package/dist/{schema-BwQtngae.d.mts → schema-CpAjXgEF.d.ts} +186 -79
- package/dist/{schema-BwQtngae.d.ts → schema-DYU1zGVm.d.mts} +186 -79
- package/dist/validators/array.d.mts +15 -0
- package/dist/validators/array.d.ts +15 -0
- package/dist/validators/array.js +31 -0
- package/dist/validators/array.mjs +2 -0
- package/dist/validators/common.d.mts +13 -0
- package/dist/validators/common.d.ts +13 -0
- package/dist/validators/common.js +27 -0
- package/dist/validators/common.mjs +2 -0
- package/dist/validators/date.d.mts +23 -0
- package/dist/validators/date.d.ts +23 -0
- package/dist/validators/date.js +47 -0
- package/dist/validators/date.mjs +2 -0
- package/dist/validators/index.d.mts +46 -0
- package/dist/validators/index.d.ts +46 -0
- package/dist/validators/index.js +256 -0
- package/dist/validators/index.mjs +7 -0
- package/dist/validators/number.d.mts +25 -0
- package/dist/validators/number.d.ts +25 -0
- package/dist/validators/number.js +51 -0
- package/dist/validators/number.mjs +2 -0
- package/dist/validators/object.d.mts +11 -0
- package/dist/validators/object.d.ts +11 -0
- package/dist/validators/object.js +23 -0
- package/dist/validators/object.mjs +2 -0
- package/dist/validators/string.d.mts +37 -0
- package/dist/validators/string.d.ts +37 -0
- package/dist/validators/string.js +75 -0
- package/dist/validators/string.mjs +2 -0
- package/package.json +36 -1
- package/dist/adapters/backend/index.js.map +0 -1
- package/dist/adapters/backend/index.mjs.map +0 -1
- package/dist/adapters/frontend/index.js.map +0 -1
- package/dist/adapters/frontend/index.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -1,81 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Core types for the FormSchema validation engine
|
|
3
|
-
*/
|
|
4
|
-
type ValidationSeverity = 'hard' | 'soft';
|
|
5
|
-
interface ValidationError {
|
|
6
|
-
/** Field path (e.g., "email" or "address.city") */
|
|
7
|
-
field: string;
|
|
8
|
-
/** Error code for programmatic handling */
|
|
9
|
-
code: string;
|
|
10
|
-
/** Human-readable error message */
|
|
11
|
-
message: string;
|
|
12
|
-
/** Severity level - hard errors block submission, soft are warnings */
|
|
13
|
-
severity: ValidationSeverity;
|
|
14
|
-
}
|
|
15
|
-
interface ValidationResult {
|
|
16
|
-
/** True if no hard errors exist */
|
|
17
|
-
valid: boolean;
|
|
18
|
-
/** Errors that block form submission */
|
|
19
|
-
hardErrors: ValidationError[];
|
|
20
|
-
/** Warnings that don't block submission */
|
|
21
|
-
softErrors: ValidationError[];
|
|
22
|
-
}
|
|
23
|
-
type FieldType = 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object';
|
|
24
|
-
interface ValidationRule {
|
|
25
|
-
/** Rule type identifier */
|
|
26
|
-
type: string;
|
|
27
|
-
/** Rule parameters */
|
|
28
|
-
params?: Record<string, unknown>;
|
|
29
|
-
/** Custom error message */
|
|
30
|
-
message?: string;
|
|
31
|
-
/** Is this a soft validation (warning only)? */
|
|
32
|
-
soft?: boolean;
|
|
33
|
-
}
|
|
34
|
-
interface FieldDefinition<T = unknown> {
|
|
35
|
-
/** The base type of this field */
|
|
36
|
-
type: FieldType;
|
|
37
|
-
/** Validation rules to apply */
|
|
38
|
-
rules: ValidationRule[];
|
|
39
|
-
/** Is this field required? */
|
|
40
|
-
required: boolean;
|
|
41
|
-
/** Default value */
|
|
42
|
-
defaultValue?: T;
|
|
43
|
-
/** For nested schemas */
|
|
44
|
-
schema?: SchemaDefinition;
|
|
45
|
-
/** For array items */
|
|
46
|
-
items?: FieldDefinition;
|
|
47
|
-
/** Field metadata */
|
|
48
|
-
meta?: Record<string, unknown>;
|
|
49
|
-
}
|
|
50
|
-
interface SchemaDefinition {
|
|
51
|
-
/** Field definitions keyed by field name */
|
|
52
|
-
fields: Record<string, FieldDefinition>;
|
|
53
|
-
/** Schema metadata */
|
|
54
|
-
meta?: Record<string, unknown>;
|
|
55
|
-
}
|
|
56
|
-
interface ValidatorContext {
|
|
57
|
-
/** Current field path */
|
|
58
|
-
path: string;
|
|
59
|
-
/** Full data object being validated */
|
|
60
|
-
root: unknown;
|
|
61
|
-
/** Parent object containing this field */
|
|
62
|
-
parent?: unknown;
|
|
63
|
-
}
|
|
64
|
-
type ValidatorFn = (value: unknown, params: Record<string, unknown> | undefined, context: ValidatorContext) => ValidationError | null;
|
|
65
|
-
interface EnterpriseValidationResponse {
|
|
66
|
-
status: 'success' | 'validation_error';
|
|
67
|
-
data?: unknown;
|
|
68
|
-
errors: ValidationError[];
|
|
69
|
-
msg: string;
|
|
70
|
-
validation: {
|
|
71
|
-
hard_validations: ValidationError[];
|
|
72
|
-
soft_validations: ValidationError[];
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Convert ValidationResult to enterprise-compatible response format
|
|
77
|
-
*/
|
|
78
|
-
declare function toEnterpriseResponse(result: ValidationResult, data?: unknown): EnterpriseValidationResponse;
|
|
1
|
+
import { f as FieldDefinition, e as ValidationRule, V as ValidatorContext, S as SchemaDefinition } from './index-BQR7OrY7.js';
|
|
79
2
|
|
|
80
3
|
/**
|
|
81
4
|
* Fluent field builder for schema definitions
|
|
@@ -118,6 +41,22 @@ declare class BaseFieldBuilder<T> {
|
|
|
118
41
|
* Add field metadata
|
|
119
42
|
*/
|
|
120
43
|
meta(data: Record<string, unknown>): this;
|
|
44
|
+
/**
|
|
45
|
+
* Field must not match another field
|
|
46
|
+
*/
|
|
47
|
+
notMatches(field: string, message?: string): this;
|
|
48
|
+
/**
|
|
49
|
+
* Field must be greater than another field (for numbers)
|
|
50
|
+
*/
|
|
51
|
+
greaterThan(field: string, message?: string): this;
|
|
52
|
+
/**
|
|
53
|
+
* Field must be less than another field (for numbers)
|
|
54
|
+
*/
|
|
55
|
+
lessThan(field: string, message?: string): this;
|
|
56
|
+
/**
|
|
57
|
+
* Field depends on another field being set
|
|
58
|
+
*/
|
|
59
|
+
dependsOn(field: string, message?: string): this;
|
|
121
60
|
/**
|
|
122
61
|
* Build the field definition
|
|
123
62
|
*/
|
|
@@ -149,6 +88,66 @@ declare class StringFieldBuilder extends BaseFieldBuilder<string> {
|
|
|
149
88
|
* Validate as URL
|
|
150
89
|
*/
|
|
151
90
|
url(message?: string): this;
|
|
91
|
+
/**
|
|
92
|
+
* Validate as IP address (IPv4)
|
|
93
|
+
*/
|
|
94
|
+
ipAddress(message?: string): this;
|
|
95
|
+
/**
|
|
96
|
+
* Validate as IPv6 address
|
|
97
|
+
*/
|
|
98
|
+
ipv6(message?: string): this;
|
|
99
|
+
/**
|
|
100
|
+
* Only alphabetic characters (a-zA-Z)
|
|
101
|
+
*/
|
|
102
|
+
alpha(message?: string): this;
|
|
103
|
+
/**
|
|
104
|
+
* Only alphanumeric characters (a-zA-Z0-9)
|
|
105
|
+
*/
|
|
106
|
+
alphanumeric(message?: string): this;
|
|
107
|
+
/**
|
|
108
|
+
* Only numeric digits
|
|
109
|
+
*/
|
|
110
|
+
numeric(message?: string): this;
|
|
111
|
+
/**
|
|
112
|
+
* Must be lowercase
|
|
113
|
+
*/
|
|
114
|
+
lowercase(message?: string): this;
|
|
115
|
+
/**
|
|
116
|
+
* Must be uppercase
|
|
117
|
+
*/
|
|
118
|
+
uppercase(message?: string): this;
|
|
119
|
+
/**
|
|
120
|
+
* URL-friendly slug (lowercase, alphanumeric, hyphens)
|
|
121
|
+
*/
|
|
122
|
+
slug(message?: string): this;
|
|
123
|
+
/**
|
|
124
|
+
* Hexadecimal string
|
|
125
|
+
*/
|
|
126
|
+
hex(message?: string): this;
|
|
127
|
+
/**
|
|
128
|
+
* Base64 encoded string
|
|
129
|
+
*/
|
|
130
|
+
base64(message?: string): this;
|
|
131
|
+
/**
|
|
132
|
+
* Valid JSON string
|
|
133
|
+
*/
|
|
134
|
+
json(message?: string): this;
|
|
135
|
+
/**
|
|
136
|
+
* Exact length
|
|
137
|
+
*/
|
|
138
|
+
length(len: number, message?: string): this;
|
|
139
|
+
/**
|
|
140
|
+
* Must contain substring
|
|
141
|
+
*/
|
|
142
|
+
contains(substring: string, message?: string): this;
|
|
143
|
+
/**
|
|
144
|
+
* Must start with prefix
|
|
145
|
+
*/
|
|
146
|
+
startsWith(prefix: string, message?: string): this;
|
|
147
|
+
/**
|
|
148
|
+
* Must end with suffix
|
|
149
|
+
*/
|
|
150
|
+
endsWith(suffix: string, message?: string): this;
|
|
152
151
|
/**
|
|
153
152
|
* Match a regex pattern
|
|
154
153
|
*/
|
|
@@ -209,6 +208,50 @@ declare class NumberFieldBuilder extends BaseFieldBuilder<number> {
|
|
|
209
208
|
* Must be negative
|
|
210
209
|
*/
|
|
211
210
|
negative(message?: string): this;
|
|
211
|
+
/**
|
|
212
|
+
* Must be a valid port number (0-65535)
|
|
213
|
+
*/
|
|
214
|
+
port(message?: string): this;
|
|
215
|
+
/**
|
|
216
|
+
* Must be a valid latitude (-90 to 90)
|
|
217
|
+
*/
|
|
218
|
+
latitude(message?: string): this;
|
|
219
|
+
/**
|
|
220
|
+
* Must be a valid longitude (-180 to 180)
|
|
221
|
+
*/
|
|
222
|
+
longitude(message?: string): this;
|
|
223
|
+
/**
|
|
224
|
+
* Must be a percentage (0-100)
|
|
225
|
+
*/
|
|
226
|
+
percentage(message?: string): this;
|
|
227
|
+
/**
|
|
228
|
+
* Must be between min and max (inclusive)
|
|
229
|
+
*/
|
|
230
|
+
between(min: number, max: number, message?: string): this;
|
|
231
|
+
/**
|
|
232
|
+
* Must be divisible by a number
|
|
233
|
+
*/
|
|
234
|
+
divisibleBy(divisor: number, message?: string): this;
|
|
235
|
+
/**
|
|
236
|
+
* Must be a multiple of a number
|
|
237
|
+
*/
|
|
238
|
+
multipleOf(multiple: number, message?: string): this;
|
|
239
|
+
/**
|
|
240
|
+
* Must be an even number
|
|
241
|
+
*/
|
|
242
|
+
even(message?: string): this;
|
|
243
|
+
/**
|
|
244
|
+
* Must be an odd number
|
|
245
|
+
*/
|
|
246
|
+
odd(message?: string): this;
|
|
247
|
+
/**
|
|
248
|
+
* Must be a safe integer
|
|
249
|
+
*/
|
|
250
|
+
safe(message?: string): this;
|
|
251
|
+
/**
|
|
252
|
+
* Must be a finite number
|
|
253
|
+
*/
|
|
254
|
+
finite(message?: string): this;
|
|
212
255
|
/**
|
|
213
256
|
* Add a soft validation with message
|
|
214
257
|
*/
|
|
@@ -251,6 +294,46 @@ declare class DateFieldBuilder extends BaseFieldBuilder<Date> {
|
|
|
251
294
|
* Must be in the future
|
|
252
295
|
*/
|
|
253
296
|
future(message?: string): this;
|
|
297
|
+
/**
|
|
298
|
+
* Must be today
|
|
299
|
+
*/
|
|
300
|
+
today(message?: string): this;
|
|
301
|
+
/**
|
|
302
|
+
* Must be yesterday
|
|
303
|
+
*/
|
|
304
|
+
yesterday(message?: string): this;
|
|
305
|
+
/**
|
|
306
|
+
* Must be tomorrow
|
|
307
|
+
*/
|
|
308
|
+
tomorrow(message?: string): this;
|
|
309
|
+
/**
|
|
310
|
+
* Must be within this week
|
|
311
|
+
*/
|
|
312
|
+
thisWeek(message?: string): this;
|
|
313
|
+
/**
|
|
314
|
+
* Must be within this month
|
|
315
|
+
*/
|
|
316
|
+
thisMonth(message?: string): this;
|
|
317
|
+
/**
|
|
318
|
+
* Must be within this year
|
|
319
|
+
*/
|
|
320
|
+
thisYear(message?: string): this;
|
|
321
|
+
/**
|
|
322
|
+
* Must be a weekday
|
|
323
|
+
*/
|
|
324
|
+
weekday(message?: string): this;
|
|
325
|
+
/**
|
|
326
|
+
* Must be a weekend
|
|
327
|
+
*/
|
|
328
|
+
weekend(message?: string): this;
|
|
329
|
+
/**
|
|
330
|
+
* Validate age is within range
|
|
331
|
+
*/
|
|
332
|
+
age(min?: number, max?: number, message?: string): this;
|
|
333
|
+
/**
|
|
334
|
+
* Must be between two dates
|
|
335
|
+
*/
|
|
336
|
+
between(start: Date | string, end: Date | string, message?: string): this;
|
|
254
337
|
}
|
|
255
338
|
declare class ArrayFieldBuilder<T> extends BaseFieldBuilder<T[]> {
|
|
256
339
|
private _itemDef?;
|
|
@@ -271,6 +354,30 @@ declare class ArrayFieldBuilder<T> extends BaseFieldBuilder<T[]> {
|
|
|
271
354
|
* All items must be unique
|
|
272
355
|
*/
|
|
273
356
|
unique(message?: string): this;
|
|
357
|
+
/**
|
|
358
|
+
* Must include a specific item
|
|
359
|
+
*/
|
|
360
|
+
includes(item: T, message?: string): this;
|
|
361
|
+
/**
|
|
362
|
+
* Must not include a specific item
|
|
363
|
+
*/
|
|
364
|
+
excludes(item: T, message?: string): this;
|
|
365
|
+
/**
|
|
366
|
+
* Must be empty
|
|
367
|
+
*/
|
|
368
|
+
empty(message?: string): this;
|
|
369
|
+
/**
|
|
370
|
+
* Must not be empty
|
|
371
|
+
*/
|
|
372
|
+
notEmpty(message?: string): this;
|
|
373
|
+
/**
|
|
374
|
+
* Must be sorted
|
|
375
|
+
*/
|
|
376
|
+
sorted(order?: 'asc' | 'desc', message?: string): this;
|
|
377
|
+
/**
|
|
378
|
+
* Must not contain falsy values
|
|
379
|
+
*/
|
|
380
|
+
compact(message?: string): this;
|
|
274
381
|
build(): FieldDefinition<T[]>;
|
|
275
382
|
}
|
|
276
383
|
declare class ObjectFieldBuilder<T extends Record<string, unknown>> extends BaseFieldBuilder<T> {
|
|
@@ -359,4 +466,4 @@ declare const field: {
|
|
|
359
466
|
enum<E extends string>(values: readonly E[]): StringFieldBuilder;
|
|
360
467
|
};
|
|
361
468
|
|
|
362
|
-
export { ArrayFieldBuilder as A, BaseFieldBuilder as B, DateFieldBuilder as D, EnumFieldBuilder as E, type
|
|
469
|
+
export { ArrayFieldBuilder as A, BaseFieldBuilder as B, DateFieldBuilder as D, EnumFieldBuilder as E, type InferInput as I, NumberFieldBuilder as N, ObjectFieldBuilder as O, type SchemaBuilder as S, partial as a, type InferOutput as b, StringFieldBuilder as c, BooleanFieldBuilder as d, extend as e, field as f, merge as m, omit as o, pick as p, schema as s };
|
|
@@ -1,81 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Core types for the FormSchema validation engine
|
|
3
|
-
*/
|
|
4
|
-
type ValidationSeverity = 'hard' | 'soft';
|
|
5
|
-
interface ValidationError {
|
|
6
|
-
/** Field path (e.g., "email" or "address.city") */
|
|
7
|
-
field: string;
|
|
8
|
-
/** Error code for programmatic handling */
|
|
9
|
-
code: string;
|
|
10
|
-
/** Human-readable error message */
|
|
11
|
-
message: string;
|
|
12
|
-
/** Severity level - hard errors block submission, soft are warnings */
|
|
13
|
-
severity: ValidationSeverity;
|
|
14
|
-
}
|
|
15
|
-
interface ValidationResult {
|
|
16
|
-
/** True if no hard errors exist */
|
|
17
|
-
valid: boolean;
|
|
18
|
-
/** Errors that block form submission */
|
|
19
|
-
hardErrors: ValidationError[];
|
|
20
|
-
/** Warnings that don't block submission */
|
|
21
|
-
softErrors: ValidationError[];
|
|
22
|
-
}
|
|
23
|
-
type FieldType = 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object';
|
|
24
|
-
interface ValidationRule {
|
|
25
|
-
/** Rule type identifier */
|
|
26
|
-
type: string;
|
|
27
|
-
/** Rule parameters */
|
|
28
|
-
params?: Record<string, unknown>;
|
|
29
|
-
/** Custom error message */
|
|
30
|
-
message?: string;
|
|
31
|
-
/** Is this a soft validation (warning only)? */
|
|
32
|
-
soft?: boolean;
|
|
33
|
-
}
|
|
34
|
-
interface FieldDefinition<T = unknown> {
|
|
35
|
-
/** The base type of this field */
|
|
36
|
-
type: FieldType;
|
|
37
|
-
/** Validation rules to apply */
|
|
38
|
-
rules: ValidationRule[];
|
|
39
|
-
/** Is this field required? */
|
|
40
|
-
required: boolean;
|
|
41
|
-
/** Default value */
|
|
42
|
-
defaultValue?: T;
|
|
43
|
-
/** For nested schemas */
|
|
44
|
-
schema?: SchemaDefinition;
|
|
45
|
-
/** For array items */
|
|
46
|
-
items?: FieldDefinition;
|
|
47
|
-
/** Field metadata */
|
|
48
|
-
meta?: Record<string, unknown>;
|
|
49
|
-
}
|
|
50
|
-
interface SchemaDefinition {
|
|
51
|
-
/** Field definitions keyed by field name */
|
|
52
|
-
fields: Record<string, FieldDefinition>;
|
|
53
|
-
/** Schema metadata */
|
|
54
|
-
meta?: Record<string, unknown>;
|
|
55
|
-
}
|
|
56
|
-
interface ValidatorContext {
|
|
57
|
-
/** Current field path */
|
|
58
|
-
path: string;
|
|
59
|
-
/** Full data object being validated */
|
|
60
|
-
root: unknown;
|
|
61
|
-
/** Parent object containing this field */
|
|
62
|
-
parent?: unknown;
|
|
63
|
-
}
|
|
64
|
-
type ValidatorFn = (value: unknown, params: Record<string, unknown> | undefined, context: ValidatorContext) => ValidationError | null;
|
|
65
|
-
interface EnterpriseValidationResponse {
|
|
66
|
-
status: 'success' | 'validation_error';
|
|
67
|
-
data?: unknown;
|
|
68
|
-
errors: ValidationError[];
|
|
69
|
-
msg: string;
|
|
70
|
-
validation: {
|
|
71
|
-
hard_validations: ValidationError[];
|
|
72
|
-
soft_validations: ValidationError[];
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Convert ValidationResult to enterprise-compatible response format
|
|
77
|
-
*/
|
|
78
|
-
declare function toEnterpriseResponse(result: ValidationResult, data?: unknown): EnterpriseValidationResponse;
|
|
1
|
+
import { f as FieldDefinition, e as ValidationRule, V as ValidatorContext, S as SchemaDefinition } from './index-BQR7OrY7.mjs';
|
|
79
2
|
|
|
80
3
|
/**
|
|
81
4
|
* Fluent field builder for schema definitions
|
|
@@ -118,6 +41,22 @@ declare class BaseFieldBuilder<T> {
|
|
|
118
41
|
* Add field metadata
|
|
119
42
|
*/
|
|
120
43
|
meta(data: Record<string, unknown>): this;
|
|
44
|
+
/**
|
|
45
|
+
* Field must not match another field
|
|
46
|
+
*/
|
|
47
|
+
notMatches(field: string, message?: string): this;
|
|
48
|
+
/**
|
|
49
|
+
* Field must be greater than another field (for numbers)
|
|
50
|
+
*/
|
|
51
|
+
greaterThan(field: string, message?: string): this;
|
|
52
|
+
/**
|
|
53
|
+
* Field must be less than another field (for numbers)
|
|
54
|
+
*/
|
|
55
|
+
lessThan(field: string, message?: string): this;
|
|
56
|
+
/**
|
|
57
|
+
* Field depends on another field being set
|
|
58
|
+
*/
|
|
59
|
+
dependsOn(field: string, message?: string): this;
|
|
121
60
|
/**
|
|
122
61
|
* Build the field definition
|
|
123
62
|
*/
|
|
@@ -149,6 +88,66 @@ declare class StringFieldBuilder extends BaseFieldBuilder<string> {
|
|
|
149
88
|
* Validate as URL
|
|
150
89
|
*/
|
|
151
90
|
url(message?: string): this;
|
|
91
|
+
/**
|
|
92
|
+
* Validate as IP address (IPv4)
|
|
93
|
+
*/
|
|
94
|
+
ipAddress(message?: string): this;
|
|
95
|
+
/**
|
|
96
|
+
* Validate as IPv6 address
|
|
97
|
+
*/
|
|
98
|
+
ipv6(message?: string): this;
|
|
99
|
+
/**
|
|
100
|
+
* Only alphabetic characters (a-zA-Z)
|
|
101
|
+
*/
|
|
102
|
+
alpha(message?: string): this;
|
|
103
|
+
/**
|
|
104
|
+
* Only alphanumeric characters (a-zA-Z0-9)
|
|
105
|
+
*/
|
|
106
|
+
alphanumeric(message?: string): this;
|
|
107
|
+
/**
|
|
108
|
+
* Only numeric digits
|
|
109
|
+
*/
|
|
110
|
+
numeric(message?: string): this;
|
|
111
|
+
/**
|
|
112
|
+
* Must be lowercase
|
|
113
|
+
*/
|
|
114
|
+
lowercase(message?: string): this;
|
|
115
|
+
/**
|
|
116
|
+
* Must be uppercase
|
|
117
|
+
*/
|
|
118
|
+
uppercase(message?: string): this;
|
|
119
|
+
/**
|
|
120
|
+
* URL-friendly slug (lowercase, alphanumeric, hyphens)
|
|
121
|
+
*/
|
|
122
|
+
slug(message?: string): this;
|
|
123
|
+
/**
|
|
124
|
+
* Hexadecimal string
|
|
125
|
+
*/
|
|
126
|
+
hex(message?: string): this;
|
|
127
|
+
/**
|
|
128
|
+
* Base64 encoded string
|
|
129
|
+
*/
|
|
130
|
+
base64(message?: string): this;
|
|
131
|
+
/**
|
|
132
|
+
* Valid JSON string
|
|
133
|
+
*/
|
|
134
|
+
json(message?: string): this;
|
|
135
|
+
/**
|
|
136
|
+
* Exact length
|
|
137
|
+
*/
|
|
138
|
+
length(len: number, message?: string): this;
|
|
139
|
+
/**
|
|
140
|
+
* Must contain substring
|
|
141
|
+
*/
|
|
142
|
+
contains(substring: string, message?: string): this;
|
|
143
|
+
/**
|
|
144
|
+
* Must start with prefix
|
|
145
|
+
*/
|
|
146
|
+
startsWith(prefix: string, message?: string): this;
|
|
147
|
+
/**
|
|
148
|
+
* Must end with suffix
|
|
149
|
+
*/
|
|
150
|
+
endsWith(suffix: string, message?: string): this;
|
|
152
151
|
/**
|
|
153
152
|
* Match a regex pattern
|
|
154
153
|
*/
|
|
@@ -209,6 +208,50 @@ declare class NumberFieldBuilder extends BaseFieldBuilder<number> {
|
|
|
209
208
|
* Must be negative
|
|
210
209
|
*/
|
|
211
210
|
negative(message?: string): this;
|
|
211
|
+
/**
|
|
212
|
+
* Must be a valid port number (0-65535)
|
|
213
|
+
*/
|
|
214
|
+
port(message?: string): this;
|
|
215
|
+
/**
|
|
216
|
+
* Must be a valid latitude (-90 to 90)
|
|
217
|
+
*/
|
|
218
|
+
latitude(message?: string): this;
|
|
219
|
+
/**
|
|
220
|
+
* Must be a valid longitude (-180 to 180)
|
|
221
|
+
*/
|
|
222
|
+
longitude(message?: string): this;
|
|
223
|
+
/**
|
|
224
|
+
* Must be a percentage (0-100)
|
|
225
|
+
*/
|
|
226
|
+
percentage(message?: string): this;
|
|
227
|
+
/**
|
|
228
|
+
* Must be between min and max (inclusive)
|
|
229
|
+
*/
|
|
230
|
+
between(min: number, max: number, message?: string): this;
|
|
231
|
+
/**
|
|
232
|
+
* Must be divisible by a number
|
|
233
|
+
*/
|
|
234
|
+
divisibleBy(divisor: number, message?: string): this;
|
|
235
|
+
/**
|
|
236
|
+
* Must be a multiple of a number
|
|
237
|
+
*/
|
|
238
|
+
multipleOf(multiple: number, message?: string): this;
|
|
239
|
+
/**
|
|
240
|
+
* Must be an even number
|
|
241
|
+
*/
|
|
242
|
+
even(message?: string): this;
|
|
243
|
+
/**
|
|
244
|
+
* Must be an odd number
|
|
245
|
+
*/
|
|
246
|
+
odd(message?: string): this;
|
|
247
|
+
/**
|
|
248
|
+
* Must be a safe integer
|
|
249
|
+
*/
|
|
250
|
+
safe(message?: string): this;
|
|
251
|
+
/**
|
|
252
|
+
* Must be a finite number
|
|
253
|
+
*/
|
|
254
|
+
finite(message?: string): this;
|
|
212
255
|
/**
|
|
213
256
|
* Add a soft validation with message
|
|
214
257
|
*/
|
|
@@ -251,6 +294,46 @@ declare class DateFieldBuilder extends BaseFieldBuilder<Date> {
|
|
|
251
294
|
* Must be in the future
|
|
252
295
|
*/
|
|
253
296
|
future(message?: string): this;
|
|
297
|
+
/**
|
|
298
|
+
* Must be today
|
|
299
|
+
*/
|
|
300
|
+
today(message?: string): this;
|
|
301
|
+
/**
|
|
302
|
+
* Must be yesterday
|
|
303
|
+
*/
|
|
304
|
+
yesterday(message?: string): this;
|
|
305
|
+
/**
|
|
306
|
+
* Must be tomorrow
|
|
307
|
+
*/
|
|
308
|
+
tomorrow(message?: string): this;
|
|
309
|
+
/**
|
|
310
|
+
* Must be within this week
|
|
311
|
+
*/
|
|
312
|
+
thisWeek(message?: string): this;
|
|
313
|
+
/**
|
|
314
|
+
* Must be within this month
|
|
315
|
+
*/
|
|
316
|
+
thisMonth(message?: string): this;
|
|
317
|
+
/**
|
|
318
|
+
* Must be within this year
|
|
319
|
+
*/
|
|
320
|
+
thisYear(message?: string): this;
|
|
321
|
+
/**
|
|
322
|
+
* Must be a weekday
|
|
323
|
+
*/
|
|
324
|
+
weekday(message?: string): this;
|
|
325
|
+
/**
|
|
326
|
+
* Must be a weekend
|
|
327
|
+
*/
|
|
328
|
+
weekend(message?: string): this;
|
|
329
|
+
/**
|
|
330
|
+
* Validate age is within range
|
|
331
|
+
*/
|
|
332
|
+
age(min?: number, max?: number, message?: string): this;
|
|
333
|
+
/**
|
|
334
|
+
* Must be between two dates
|
|
335
|
+
*/
|
|
336
|
+
between(start: Date | string, end: Date | string, message?: string): this;
|
|
254
337
|
}
|
|
255
338
|
declare class ArrayFieldBuilder<T> extends BaseFieldBuilder<T[]> {
|
|
256
339
|
private _itemDef?;
|
|
@@ -271,6 +354,30 @@ declare class ArrayFieldBuilder<T> extends BaseFieldBuilder<T[]> {
|
|
|
271
354
|
* All items must be unique
|
|
272
355
|
*/
|
|
273
356
|
unique(message?: string): this;
|
|
357
|
+
/**
|
|
358
|
+
* Must include a specific item
|
|
359
|
+
*/
|
|
360
|
+
includes(item: T, message?: string): this;
|
|
361
|
+
/**
|
|
362
|
+
* Must not include a specific item
|
|
363
|
+
*/
|
|
364
|
+
excludes(item: T, message?: string): this;
|
|
365
|
+
/**
|
|
366
|
+
* Must be empty
|
|
367
|
+
*/
|
|
368
|
+
empty(message?: string): this;
|
|
369
|
+
/**
|
|
370
|
+
* Must not be empty
|
|
371
|
+
*/
|
|
372
|
+
notEmpty(message?: string): this;
|
|
373
|
+
/**
|
|
374
|
+
* Must be sorted
|
|
375
|
+
*/
|
|
376
|
+
sorted(order?: 'asc' | 'desc', message?: string): this;
|
|
377
|
+
/**
|
|
378
|
+
* Must not contain falsy values
|
|
379
|
+
*/
|
|
380
|
+
compact(message?: string): this;
|
|
274
381
|
build(): FieldDefinition<T[]>;
|
|
275
382
|
}
|
|
276
383
|
declare class ObjectFieldBuilder<T extends Record<string, unknown>> extends BaseFieldBuilder<T> {
|
|
@@ -359,4 +466,4 @@ declare const field: {
|
|
|
359
466
|
enum<E extends string>(values: readonly E[]): StringFieldBuilder;
|
|
360
467
|
};
|
|
361
468
|
|
|
362
|
-
export { ArrayFieldBuilder as A, BaseFieldBuilder as B, DateFieldBuilder as D, EnumFieldBuilder as E, type
|
|
469
|
+
export { ArrayFieldBuilder as A, BaseFieldBuilder as B, DateFieldBuilder as D, EnumFieldBuilder as E, type InferInput as I, NumberFieldBuilder as N, ObjectFieldBuilder as O, type SchemaBuilder as S, partial as a, type InferOutput as b, StringFieldBuilder as c, BooleanFieldBuilder as d, extend as e, field as f, merge as m, omit as o, pick as p, schema as s };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { c as ValidatorFn } from '../index-BQR7OrY7.mjs';
|
|
2
|
+
|
|
3
|
+
declare const includesValidator: ValidatorFn;
|
|
4
|
+
|
|
5
|
+
declare const excludesValidator: ValidatorFn;
|
|
6
|
+
|
|
7
|
+
declare const emptyValidator: ValidatorFn;
|
|
8
|
+
|
|
9
|
+
declare const notEmptyValidator: ValidatorFn;
|
|
10
|
+
|
|
11
|
+
declare const sortedValidator: ValidatorFn;
|
|
12
|
+
|
|
13
|
+
declare const compactValidator: ValidatorFn;
|
|
14
|
+
|
|
15
|
+
export { compactValidator, emptyValidator, excludesValidator, includesValidator, notEmptyValidator, sortedValidator };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { c as ValidatorFn } from '../index-BQR7OrY7.js';
|
|
2
|
+
|
|
3
|
+
declare const includesValidator: ValidatorFn;
|
|
4
|
+
|
|
5
|
+
declare const excludesValidator: ValidatorFn;
|
|
6
|
+
|
|
7
|
+
declare const emptyValidator: ValidatorFn;
|
|
8
|
+
|
|
9
|
+
declare const notEmptyValidator: ValidatorFn;
|
|
10
|
+
|
|
11
|
+
declare const sortedValidator: ValidatorFn;
|
|
12
|
+
|
|
13
|
+
declare const compactValidator: ValidatorFn;
|
|
14
|
+
|
|
15
|
+
export { compactValidator, emptyValidator, excludesValidator, includesValidator, notEmptyValidator, sortedValidator };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkASKTY6EG_js = require('../chunk-ASKTY6EG.js');
|
|
4
|
+
require('../chunk-NUW55QTO.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "compactValidator", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkASKTY6EG_js.compactValidator; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "emptyValidator", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkASKTY6EG_js.emptyValidator; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "excludesValidator", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkASKTY6EG_js.excludesValidator; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "includesValidator", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkASKTY6EG_js.includesValidator; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "notEmptyValidator", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunkASKTY6EG_js.notEmptyValidator; }
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "sortedValidator", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return chunkASKTY6EG_js.sortedValidator; }
|
|
31
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { c as ValidatorFn } from '../index-BQR7OrY7.mjs';
|
|
2
|
+
|
|
3
|
+
declare const notMatchesValidator: ValidatorFn;
|
|
4
|
+
|
|
5
|
+
declare const greaterThanValidator: ValidatorFn;
|
|
6
|
+
|
|
7
|
+
declare const lessThanValidator: ValidatorFn;
|
|
8
|
+
|
|
9
|
+
declare const whenValidator: ValidatorFn;
|
|
10
|
+
|
|
11
|
+
declare const dependsOnValidator: ValidatorFn;
|
|
12
|
+
|
|
13
|
+
export { dependsOnValidator, greaterThanValidator, lessThanValidator, notMatchesValidator, whenValidator };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { c as ValidatorFn } from '../index-BQR7OrY7.js';
|
|
2
|
+
|
|
3
|
+
declare const notMatchesValidator: ValidatorFn;
|
|
4
|
+
|
|
5
|
+
declare const greaterThanValidator: ValidatorFn;
|
|
6
|
+
|
|
7
|
+
declare const lessThanValidator: ValidatorFn;
|
|
8
|
+
|
|
9
|
+
declare const whenValidator: ValidatorFn;
|
|
10
|
+
|
|
11
|
+
declare const dependsOnValidator: ValidatorFn;
|
|
12
|
+
|
|
13
|
+
export { dependsOnValidator, greaterThanValidator, lessThanValidator, notMatchesValidator, whenValidator };
|