@sinclair/typebox 0.32.12 → 0.32.14
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/build/import/compiler/compiler.mjs +4 -0
- package/build/import/errors/errors.mjs +8 -0
- package/build/import/index.d.mts +69 -69
- package/build/import/index.mjs +69 -76
- package/build/import/type/clone/index.d.mts +2 -2
- package/build/import/type/clone/index.mjs +2 -2
- package/build/import/type/const/const.mjs +2 -2
- package/build/import/type/guard/type.mjs +3 -1
- package/build/import/type/object/object.d.mts +1 -1
- package/build/import/type/object/object.mjs +1 -1
- package/build/import/type/regexp/regexp.d.mts +8 -2
- package/build/import/type/type/javascript.d.mts +3 -3
- package/build/import/value/check/check.mjs +8 -0
- package/build/require/compiler/compiler.js +4 -0
- package/build/require/errors/errors.js +8 -0
- package/build/require/index.d.ts +69 -69
- package/build/require/index.js +83 -202
- package/build/require/type/clone/index.d.ts +2 -2
- package/build/require/type/clone/index.js +16 -3
- package/build/require/type/const/const.js +1 -1
- package/build/require/type/guard/type.js +3 -1
- package/build/require/type/object/object.d.ts +1 -1
- package/build/require/type/object/object.js +1 -2
- package/build/require/type/regexp/regexp.d.ts +8 -2
- package/build/require/type/type/javascript.d.ts +3 -3
- package/build/require/value/check/check.js +8 -0
- package/package.json +1 -1
|
@@ -387,6 +387,10 @@ export var TypeCompiler;
|
|
|
387
387
|
function* FromRegExp(schema, references, value) {
|
|
388
388
|
const variable = CreateVariable(`${new RegExp(schema.source, schema.flags)};`);
|
|
389
389
|
yield `(typeof ${value} === 'string')`;
|
|
390
|
+
if (IsNumber(schema.maxLength))
|
|
391
|
+
yield `${value}.length <= ${schema.maxLength}`;
|
|
392
|
+
if (IsNumber(schema.minLength))
|
|
393
|
+
yield `${value}.length >= ${schema.minLength}`;
|
|
390
394
|
yield `${variable}.test(${value})`;
|
|
391
395
|
}
|
|
392
396
|
function* FromString(schema, references, value) {
|
|
@@ -393,6 +393,14 @@ function* FromRef(schema, references, path, value) {
|
|
|
393
393
|
yield* Visit(Deref(schema, references), references, path, value);
|
|
394
394
|
}
|
|
395
395
|
function* FromRegExp(schema, references, path, value) {
|
|
396
|
+
if (!IsString(value))
|
|
397
|
+
return yield Create(ValueErrorType.String, schema, path, value);
|
|
398
|
+
if (IsDefined(schema.minLength) && !(value.length >= schema.minLength)) {
|
|
399
|
+
yield Create(ValueErrorType.StringMinLength, schema, path, value);
|
|
400
|
+
}
|
|
401
|
+
if (IsDefined(schema.maxLength) && !(value.length <= schema.maxLength)) {
|
|
402
|
+
yield Create(ValueErrorType.StringMaxLength, schema, path, value);
|
|
403
|
+
}
|
|
396
404
|
const regex = new RegExp(schema.source, schema.flags);
|
|
397
405
|
if (!regex.test(value)) {
|
|
398
406
|
return yield Create(ValueErrorType.RegExp, schema, path, value);
|
package/build/import/index.d.mts
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
50
|
-
export
|
|
51
|
-
export
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
1
|
+
export * from './type/clone/index.mjs';
|
|
2
|
+
export * from './type/error/index.mjs';
|
|
3
|
+
export * from './type/guard/index.mjs';
|
|
4
|
+
export * from './type/helpers/index.mjs';
|
|
5
|
+
export * from './type/patterns/index.mjs';
|
|
6
|
+
export * from './type/registry/index.mjs';
|
|
7
|
+
export * from './type/sets/index.mjs';
|
|
8
|
+
export * from './type/symbols/index.mjs';
|
|
9
|
+
export * from './type/any/index.mjs';
|
|
10
|
+
export * from './type/array/index.mjs';
|
|
11
|
+
export * from './type/async-iterator/index.mjs';
|
|
12
|
+
export * from './type/awaited/index.mjs';
|
|
13
|
+
export * from './type/bigint/index.mjs';
|
|
14
|
+
export * from './type/boolean/index.mjs';
|
|
15
|
+
export * from './type/composite/index.mjs';
|
|
16
|
+
export * from './type/const/index.mjs';
|
|
17
|
+
export * from './type/constructor/index.mjs';
|
|
18
|
+
export * from './type/constructor-parameters/index.mjs';
|
|
19
|
+
export * from './type/date/index.mjs';
|
|
20
|
+
export * from './type/deref/index.mjs';
|
|
21
|
+
export * from './type/enum/index.mjs';
|
|
22
|
+
export * from './type/exclude/index.mjs';
|
|
23
|
+
export * from './type/extends/index.mjs';
|
|
24
|
+
export * from './type/extract/index.mjs';
|
|
25
|
+
export * from './type/function/index.mjs';
|
|
26
|
+
export * from './type/indexed/index.mjs';
|
|
27
|
+
export * from './type/instance-type/index.mjs';
|
|
28
|
+
export * from './type/integer/index.mjs';
|
|
29
|
+
export * from './type/intersect/index.mjs';
|
|
30
|
+
export * from './type/iterator/index.mjs';
|
|
31
|
+
export * from './type/intrinsic/index.mjs';
|
|
32
|
+
export * from './type/keyof/index.mjs';
|
|
33
|
+
export * from './type/literal/index.mjs';
|
|
34
|
+
export * from './type/mapped/index.mjs';
|
|
35
|
+
export * from './type/never/index.mjs';
|
|
36
|
+
export * from './type/not/index.mjs';
|
|
37
|
+
export * from './type/null/index.mjs';
|
|
38
|
+
export * from './type/number/index.mjs';
|
|
39
|
+
export * from './type/object/index.mjs';
|
|
40
|
+
export * from './type/omit/index.mjs';
|
|
41
|
+
export * from './type/optional/index.mjs';
|
|
42
|
+
export * from './type/parameters/index.mjs';
|
|
43
|
+
export * from './type/partial/index.mjs';
|
|
44
|
+
export * from './type/pick/index.mjs';
|
|
45
|
+
export * from './type/promise/index.mjs';
|
|
46
|
+
export * from './type/readonly/index.mjs';
|
|
47
|
+
export * from './type/readonly-optional/index.mjs';
|
|
48
|
+
export * from './type/record/index.mjs';
|
|
49
|
+
export * from './type/recursive/index.mjs';
|
|
50
|
+
export * from './type/ref/index.mjs';
|
|
51
|
+
export * from './type/regexp/index.mjs';
|
|
52
|
+
export * from './type/required/index.mjs';
|
|
53
|
+
export * from './type/rest/index.mjs';
|
|
54
|
+
export * from './type/return-type/index.mjs';
|
|
55
|
+
export * from './type/schema/index.mjs';
|
|
56
|
+
export * from './type/static/index.mjs';
|
|
57
|
+
export * from './type/strict/index.mjs';
|
|
58
|
+
export * from './type/string/index.mjs';
|
|
59
|
+
export * from './type/symbol/index.mjs';
|
|
60
|
+
export * from './type/template-literal/index.mjs';
|
|
61
|
+
export * from './type/transform/index.mjs';
|
|
62
|
+
export * from './type/tuple/index.mjs';
|
|
63
|
+
export * from './type/uint8array/index.mjs';
|
|
64
|
+
export * from './type/undefined/index.mjs';
|
|
65
|
+
export * from './type/union/index.mjs';
|
|
66
|
+
export * from './type/unknown/index.mjs';
|
|
67
|
+
export * from './type/unsafe/index.mjs';
|
|
68
|
+
export * from './type/void/index.mjs';
|
|
69
|
+
export * from './type/type/index.mjs';
|
package/build/import/index.mjs
CHANGED
|
@@ -1,85 +1,78 @@
|
|
|
1
1
|
// ------------------------------------------------------------------
|
|
2
2
|
// Infrastructure
|
|
3
3
|
// ------------------------------------------------------------------
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export { TypeBoxError } from './type/error/index.mjs';
|
|
13
|
-
// ------------------------------------------------------------------
|
|
14
|
-
// Sets
|
|
15
|
-
// ------------------------------------------------------------------
|
|
16
|
-
export { SetComplement, SetDistinct, SetIncludes, SetIntersect, SetIntersectMany, SetIsSubset, SetUnion, SetUnionMany, } from './type/sets/index.mjs';
|
|
17
|
-
// ------------------------------------------------------------------
|
|
18
|
-
// Helpers
|
|
19
|
-
// ------------------------------------------------------------------
|
|
20
|
-
export { Increment } from './type/helpers/index.mjs';
|
|
4
|
+
export * from './type/clone/index.mjs';
|
|
5
|
+
export * from './type/error/index.mjs';
|
|
6
|
+
export * from './type/guard/index.mjs';
|
|
7
|
+
export * from './type/helpers/index.mjs';
|
|
8
|
+
export * from './type/patterns/index.mjs';
|
|
9
|
+
export * from './type/registry/index.mjs';
|
|
10
|
+
export * from './type/sets/index.mjs';
|
|
11
|
+
export * from './type/symbols/index.mjs';
|
|
21
12
|
// ------------------------------------------------------------------
|
|
22
13
|
// Types
|
|
23
14
|
// ------------------------------------------------------------------
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
50
|
-
export
|
|
51
|
-
export
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
export
|
|
71
|
-
export
|
|
72
|
-
export
|
|
73
|
-
export
|
|
74
|
-
export
|
|
75
|
-
export
|
|
76
|
-
export
|
|
77
|
-
export
|
|
78
|
-
export
|
|
79
|
-
export
|
|
80
|
-
export
|
|
81
|
-
export
|
|
15
|
+
export * from './type/any/index.mjs';
|
|
16
|
+
export * from './type/array/index.mjs';
|
|
17
|
+
export * from './type/async-iterator/index.mjs';
|
|
18
|
+
export * from './type/awaited/index.mjs';
|
|
19
|
+
export * from './type/bigint/index.mjs';
|
|
20
|
+
export * from './type/boolean/index.mjs';
|
|
21
|
+
export * from './type/composite/index.mjs';
|
|
22
|
+
export * from './type/const/index.mjs';
|
|
23
|
+
export * from './type/constructor/index.mjs';
|
|
24
|
+
export * from './type/constructor-parameters/index.mjs';
|
|
25
|
+
export * from './type/date/index.mjs';
|
|
26
|
+
export * from './type/deref/index.mjs';
|
|
27
|
+
export * from './type/enum/index.mjs';
|
|
28
|
+
export * from './type/exclude/index.mjs';
|
|
29
|
+
export * from './type/extends/index.mjs';
|
|
30
|
+
export * from './type/extract/index.mjs';
|
|
31
|
+
export * from './type/function/index.mjs';
|
|
32
|
+
export * from './type/indexed/index.mjs';
|
|
33
|
+
export * from './type/instance-type/index.mjs';
|
|
34
|
+
export * from './type/integer/index.mjs';
|
|
35
|
+
export * from './type/intersect/index.mjs';
|
|
36
|
+
export * from './type/iterator/index.mjs';
|
|
37
|
+
export * from './type/intrinsic/index.mjs';
|
|
38
|
+
export * from './type/keyof/index.mjs';
|
|
39
|
+
export * from './type/literal/index.mjs';
|
|
40
|
+
export * from './type/mapped/index.mjs';
|
|
41
|
+
export * from './type/never/index.mjs';
|
|
42
|
+
export * from './type/not/index.mjs';
|
|
43
|
+
export * from './type/null/index.mjs';
|
|
44
|
+
export * from './type/number/index.mjs';
|
|
45
|
+
export * from './type/object/index.mjs';
|
|
46
|
+
export * from './type/omit/index.mjs';
|
|
47
|
+
export * from './type/optional/index.mjs';
|
|
48
|
+
export * from './type/parameters/index.mjs';
|
|
49
|
+
export * from './type/partial/index.mjs';
|
|
50
|
+
export * from './type/pick/index.mjs';
|
|
51
|
+
export * from './type/promise/index.mjs';
|
|
52
|
+
export * from './type/readonly/index.mjs';
|
|
53
|
+
export * from './type/readonly-optional/index.mjs';
|
|
54
|
+
export * from './type/record/index.mjs';
|
|
55
|
+
export * from './type/recursive/index.mjs';
|
|
56
|
+
export * from './type/ref/index.mjs';
|
|
57
|
+
export * from './type/regexp/index.mjs';
|
|
58
|
+
export * from './type/required/index.mjs';
|
|
59
|
+
export * from './type/rest/index.mjs';
|
|
60
|
+
export * from './type/return-type/index.mjs';
|
|
61
|
+
export * from './type/schema/index.mjs';
|
|
62
|
+
export * from './type/static/index.mjs';
|
|
63
|
+
export * from './type/strict/index.mjs';
|
|
64
|
+
export * from './type/string/index.mjs';
|
|
65
|
+
export * from './type/symbol/index.mjs';
|
|
66
|
+
export * from './type/template-literal/index.mjs';
|
|
67
|
+
export * from './type/transform/index.mjs';
|
|
68
|
+
export * from './type/tuple/index.mjs';
|
|
69
|
+
export * from './type/uint8array/index.mjs';
|
|
70
|
+
export * from './type/undefined/index.mjs';
|
|
71
|
+
export * from './type/union/index.mjs';
|
|
72
|
+
export * from './type/unknown/index.mjs';
|
|
73
|
+
export * from './type/unsafe/index.mjs';
|
|
74
|
+
export * from './type/void/index.mjs';
|
|
82
75
|
// ------------------------------------------------------------------
|
|
83
76
|
// Namespace
|
|
84
77
|
// ------------------------------------------------------------------
|
|
85
|
-
export
|
|
78
|
+
export * from './type/type/index.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export *
|
|
2
|
-
export *
|
|
1
|
+
export * from './type.mjs';
|
|
2
|
+
export * from './value.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export *
|
|
2
|
-
export *
|
|
1
|
+
export * from './type.mjs';
|
|
2
|
+
export * from './value.mjs';
|
|
@@ -11,7 +11,7 @@ import { Readonly } from '../readonly/index.mjs';
|
|
|
11
11
|
import { Undefined } from '../undefined/index.mjs';
|
|
12
12
|
import { Uint8Array } from '../uint8array/index.mjs';
|
|
13
13
|
import { Unknown } from '../unknown/index.mjs';
|
|
14
|
-
import {
|
|
14
|
+
import { CloneType } from '../clone/index.mjs';
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
16
|
// ValueGuard
|
|
17
17
|
// ------------------------------------------------------------------
|
|
@@ -49,5 +49,5 @@ function FromValue(value, root) {
|
|
|
49
49
|
}
|
|
50
50
|
/** `[JavaScript]` Creates a readonly const type from the given value. */
|
|
51
51
|
export function Const(T, options = {}) {
|
|
52
|
-
return
|
|
52
|
+
return CloneType(FromValue(T, true), options);
|
|
53
53
|
}
|
|
@@ -331,7 +331,9 @@ export function IsRegExp(value) {
|
|
|
331
331
|
return (IsKindOf(value, 'RegExp') &&
|
|
332
332
|
IsOptionalString(value.$id) &&
|
|
333
333
|
ValueGuard.IsString(value.source) &&
|
|
334
|
-
ValueGuard.IsString(value.flags)
|
|
334
|
+
ValueGuard.IsString(value.flags) &&
|
|
335
|
+
IsOptionalNumber(value.maxLength) &&
|
|
336
|
+
IsOptionalNumber(value.minLength));
|
|
335
337
|
}
|
|
336
338
|
/** Returns true if the given value is TString */
|
|
337
339
|
export function IsString(value) {
|
|
@@ -38,7 +38,7 @@ export interface TObject<T extends TProperties = TProperties> extends TSchema, O
|
|
|
38
38
|
required?: string[];
|
|
39
39
|
}
|
|
40
40
|
/** `[Json]` Creates an Object type */
|
|
41
|
-
|
|
41
|
+
declare function _Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
42
42
|
/** `[Json]` Creates an Object type */
|
|
43
43
|
export declare const Object: typeof _Object;
|
|
44
44
|
export {};
|
|
@@ -5,7 +5,7 @@ import { Kind } from '../symbols/index.mjs';
|
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
6
|
import { IsOptional, IsSchema } from '../guard/type.mjs';
|
|
7
7
|
/** `[Json]` Creates an Object type */
|
|
8
|
-
|
|
8
|
+
function _Object(properties, options = {}) {
|
|
9
9
|
const propertyKeys = globalThis.Object.getOwnPropertyNames(properties);
|
|
10
10
|
const optionalKeys = propertyKeys.filter((key) => IsOptional(properties[key]));
|
|
11
11
|
const requiredKeys = propertyKeys.filter((name) => !optionalKeys.includes(name));
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { SchemaOptions } from '../schema/index.mjs';
|
|
2
2
|
import type { TSchema } from '../schema/index.mjs';
|
|
3
3
|
import { Kind } from '../symbols/index.mjs';
|
|
4
|
+
export interface RegExpOptions extends SchemaOptions {
|
|
5
|
+
/** The maximum length of the string */
|
|
6
|
+
maxLength?: number;
|
|
7
|
+
/** The minimum length of the string */
|
|
8
|
+
minLength?: number;
|
|
9
|
+
}
|
|
4
10
|
export interface TRegExp extends TSchema {
|
|
5
11
|
[Kind]: 'RegExp';
|
|
6
12
|
static: `${string}`;
|
|
@@ -9,6 +15,6 @@ export interface TRegExp extends TSchema {
|
|
|
9
15
|
flags: string;
|
|
10
16
|
}
|
|
11
17
|
/** `[JavaScript]` Creates a RegExp type */
|
|
12
|
-
export declare function RegExp(pattern: string, options?:
|
|
18
|
+
export declare function RegExp(pattern: string, options?: RegExpOptions): TRegExp;
|
|
13
19
|
/** `[JavaScript]` Creates a RegExp type */
|
|
14
|
-
export declare function RegExp(regex: RegExp, options?:
|
|
20
|
+
export declare function RegExp(regex: RegExp, options?: RegExpOptions): TRegExp;
|
|
@@ -10,7 +10,7 @@ import { type TInstanceType } from '../instance-type/index.mjs';
|
|
|
10
10
|
import { type TIterator } from '../iterator/index.mjs';
|
|
11
11
|
import { type TParameters } from '../parameters/index.mjs';
|
|
12
12
|
import { type TPromise } from '../promise/index.mjs';
|
|
13
|
-
import { type TRegExp } from '../regexp/index.mjs';
|
|
13
|
+
import { type TRegExp, RegExpOptions } from '../regexp/index.mjs';
|
|
14
14
|
import { type TReturnType } from '../return-type/index.mjs';
|
|
15
15
|
import { type TSchema, type SchemaOptions } from '../schema/index.mjs';
|
|
16
16
|
import { type TSymbol } from '../symbol/index.mjs';
|
|
@@ -42,9 +42,9 @@ export declare class JavaScriptTypeBuilder extends JsonTypeBuilder {
|
|
|
42
42
|
/** `[JavaScript]` Creates a Promise type */
|
|
43
43
|
Promise<T extends TSchema>(item: T, options?: SchemaOptions): TPromise<T>;
|
|
44
44
|
/** `[JavaScript]` Creates a RegExp type */
|
|
45
|
-
RegExp(pattern: string, options?:
|
|
45
|
+
RegExp(pattern: string, options?: RegExpOptions): TRegExp;
|
|
46
46
|
/** `[JavaScript]` Creates a RegExp type */
|
|
47
|
-
RegExp(regex: RegExp, options?:
|
|
47
|
+
RegExp(regex: RegExp, options?: RegExpOptions): TRegExp;
|
|
48
48
|
/** `[JavaScript]` Extracts the ReturnType from the given Function type */
|
|
49
49
|
ReturnType<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TReturnType<T>;
|
|
50
50
|
/** `[JavaScript]` Creates a Symbol type */
|
|
@@ -287,6 +287,14 @@ function FromRef(schema, references, value) {
|
|
|
287
287
|
}
|
|
288
288
|
function FromRegExp(schema, references, value) {
|
|
289
289
|
const regex = new RegExp(schema.source, schema.flags);
|
|
290
|
+
if (IsDefined(schema.minLength)) {
|
|
291
|
+
if (!(value.length >= schema.minLength))
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
if (IsDefined(schema.maxLength)) {
|
|
295
|
+
if (!(value.length <= schema.maxLength))
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
290
298
|
return regex.test(value);
|
|
291
299
|
}
|
|
292
300
|
function FromString(schema, references, value) {
|
|
@@ -387,6 +387,10 @@ var TypeCompiler;
|
|
|
387
387
|
function* FromRegExp(schema, references, value) {
|
|
388
388
|
const variable = CreateVariable(`${new RegExp(schema.source, schema.flags)};`);
|
|
389
389
|
yield `(typeof ${value} === 'string')`;
|
|
390
|
+
if ((0, index_11.IsNumber)(schema.maxLength))
|
|
391
|
+
yield `${value}.length <= ${schema.maxLength}`;
|
|
392
|
+
if ((0, index_11.IsNumber)(schema.minLength))
|
|
393
|
+
yield `${value}.length >= ${schema.minLength}`;
|
|
390
394
|
yield `${variable}.test(${value})`;
|
|
391
395
|
}
|
|
392
396
|
function* FromString(schema, references, value) {
|
|
@@ -397,6 +397,14 @@ function* FromRef(schema, references, path, value) {
|
|
|
397
397
|
yield* Visit((0, index_5.Deref)(schema, references), references, path, value);
|
|
398
398
|
}
|
|
399
399
|
function* FromRegExp(schema, references, path, value) {
|
|
400
|
+
if (!(0, index_9.IsString)(value))
|
|
401
|
+
return yield Create(ValueErrorType.String, schema, path, value);
|
|
402
|
+
if (IsDefined(schema.minLength) && !(value.length >= schema.minLength)) {
|
|
403
|
+
yield Create(ValueErrorType.StringMinLength, schema, path, value);
|
|
404
|
+
}
|
|
405
|
+
if (IsDefined(schema.maxLength) && !(value.length <= schema.maxLength)) {
|
|
406
|
+
yield Create(ValueErrorType.StringMaxLength, schema, path, value);
|
|
407
|
+
}
|
|
400
408
|
const regex = new RegExp(schema.source, schema.flags);
|
|
401
409
|
if (!regex.test(value)) {
|
|
402
410
|
return yield Create(ValueErrorType.RegExp, schema, path, value);
|
package/build/require/index.d.ts
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
50
|
-
export
|
|
51
|
-
export
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
1
|
+
export * from './type/clone/index';
|
|
2
|
+
export * from './type/error/index';
|
|
3
|
+
export * from './type/guard/index';
|
|
4
|
+
export * from './type/helpers/index';
|
|
5
|
+
export * from './type/patterns/index';
|
|
6
|
+
export * from './type/registry/index';
|
|
7
|
+
export * from './type/sets/index';
|
|
8
|
+
export * from './type/symbols/index';
|
|
9
|
+
export * from './type/any/index';
|
|
10
|
+
export * from './type/array/index';
|
|
11
|
+
export * from './type/async-iterator/index';
|
|
12
|
+
export * from './type/awaited/index';
|
|
13
|
+
export * from './type/bigint/index';
|
|
14
|
+
export * from './type/boolean/index';
|
|
15
|
+
export * from './type/composite/index';
|
|
16
|
+
export * from './type/const/index';
|
|
17
|
+
export * from './type/constructor/index';
|
|
18
|
+
export * from './type/constructor-parameters/index';
|
|
19
|
+
export * from './type/date/index';
|
|
20
|
+
export * from './type/deref/index';
|
|
21
|
+
export * from './type/enum/index';
|
|
22
|
+
export * from './type/exclude/index';
|
|
23
|
+
export * from './type/extends/index';
|
|
24
|
+
export * from './type/extract/index';
|
|
25
|
+
export * from './type/function/index';
|
|
26
|
+
export * from './type/indexed/index';
|
|
27
|
+
export * from './type/instance-type/index';
|
|
28
|
+
export * from './type/integer/index';
|
|
29
|
+
export * from './type/intersect/index';
|
|
30
|
+
export * from './type/iterator/index';
|
|
31
|
+
export * from './type/intrinsic/index';
|
|
32
|
+
export * from './type/keyof/index';
|
|
33
|
+
export * from './type/literal/index';
|
|
34
|
+
export * from './type/mapped/index';
|
|
35
|
+
export * from './type/never/index';
|
|
36
|
+
export * from './type/not/index';
|
|
37
|
+
export * from './type/null/index';
|
|
38
|
+
export * from './type/number/index';
|
|
39
|
+
export * from './type/object/index';
|
|
40
|
+
export * from './type/omit/index';
|
|
41
|
+
export * from './type/optional/index';
|
|
42
|
+
export * from './type/parameters/index';
|
|
43
|
+
export * from './type/partial/index';
|
|
44
|
+
export * from './type/pick/index';
|
|
45
|
+
export * from './type/promise/index';
|
|
46
|
+
export * from './type/readonly/index';
|
|
47
|
+
export * from './type/readonly-optional/index';
|
|
48
|
+
export * from './type/record/index';
|
|
49
|
+
export * from './type/recursive/index';
|
|
50
|
+
export * from './type/ref/index';
|
|
51
|
+
export * from './type/regexp/index';
|
|
52
|
+
export * from './type/required/index';
|
|
53
|
+
export * from './type/rest/index';
|
|
54
|
+
export * from './type/return-type/index';
|
|
55
|
+
export * from './type/schema/index';
|
|
56
|
+
export * from './type/static/index';
|
|
57
|
+
export * from './type/strict/index';
|
|
58
|
+
export * from './type/string/index';
|
|
59
|
+
export * from './type/symbol/index';
|
|
60
|
+
export * from './type/template-literal/index';
|
|
61
|
+
export * from './type/transform/index';
|
|
62
|
+
export * from './type/tuple/index';
|
|
63
|
+
export * from './type/uint8array/index';
|
|
64
|
+
export * from './type/undefined/index';
|
|
65
|
+
export * from './type/union/index';
|
|
66
|
+
export * from './type/unknown/index';
|
|
67
|
+
export * from './type/unsafe/index';
|
|
68
|
+
export * from './type/void/index';
|
|
69
|
+
export * from './type/type/index';
|
package/build/require/index.js
CHANGED
|
@@ -1,214 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
3
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.IndexFromPropertyKeys = exports.IndexPropertyKeys = exports.Index = exports.Function = exports.Extract = exports.ExtendsUndefinedCheck = exports.ExtendsResult = exports.ExtendsCheck = exports.Extends = exports.Exclude = exports.Enum = exports.Deref = exports.Date = exports.ConstructorParameters = exports.Constructor = exports.Const = exports.Composite = exports.Boolean = exports.BigInt = exports.Awaited = exports.AsyncIterator = exports.Array = exports.Any = exports.Increment = exports.SetUnionMany = exports.SetUnion = exports.SetIsSubset = exports.SetIntersectMany = exports.SetIntersect = exports.SetIncludes = exports.SetDistinct = exports.SetComplement = exports.TypeBoxError = exports.CloneRest = exports.CloneType = exports.ValueGuard = exports.TypeGuard = exports.FormatRegistry = exports.TypeRegistry = exports.PatternStringExact = exports.PatternString = exports.PatternNumberExact = exports.PatternNumber = exports.PatternBooleanExact = exports.PatternBoolean = exports.TransformKind = exports.OptionalKind = exports.ReadonlyKind = exports.Hint = exports.Kind = void 0;
|
|
5
|
-
exports.Symbol = exports.String = exports.Strict = exports.ReturnType = exports.Rest = exports.Required = exports.RegExp = exports.Ref = exports.Recursive = exports.Record = exports.ReadonlyOptional = exports.ReadonlyFromMappedResult = exports.Readonly = exports.Promise = exports.Pick = exports.PartialFromMappedResult = exports.Partial = exports.Parameters = exports.OptionalFromMappedResult = exports.Optional = exports.Omit = exports.Object = exports.Number = exports.Null = exports.Not = exports.Never = exports.MappedFunctionReturnType = exports.MappedResult = exports.MappedKey = exports.Mapped = exports.Literal = exports.KeyOfPattern = exports.KeyOfFromMappedResult = exports.KeyOfPropertyKeysToRest = exports.KeyOfPropertyKeys = exports.KeyOf = exports.Uppercase = exports.Uncapitalize = exports.Lowercase = exports.Capitalize = exports.IntrinsicFromMappedKey = exports.Intrinsic = exports.Iterator = exports.IntersectEvaluated = exports.Intersect = exports.Integer = exports.InstanceType = exports.IndexFromMappedResult = exports.IndexFromMappedKey = exports.IndexFromPropertyKey = void 0;
|
|
6
|
-
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = exports.Type = exports.Void = exports.Unsafe = exports.Unknown = exports.UnionEvaluated = exports.Union = exports.Undefined = exports.Uint8Array = exports.Tuple = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = exports.Transform = exports.IsTemplateLiteralExpressionFinite = exports.TemplateLiteralExpressionGenerate = exports.IsTemplateLiteralFinite = exports.TemplateLiteralToUnion = exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.TemplateLiteralGenerate = exports.TemplateLiteralSyntax = exports.TemplateLiteral = void 0;
|
|
7
18
|
// ------------------------------------------------------------------
|
|
8
19
|
// Infrastructure
|
|
9
20
|
// ------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(exports, "PatternBooleanExact", { enumerable: true, get: function () { return index_2.PatternBooleanExact; } });
|
|
19
|
-
Object.defineProperty(exports, "PatternNumber", { enumerable: true, get: function () { return index_2.PatternNumber; } });
|
|
20
|
-
Object.defineProperty(exports, "PatternNumberExact", { enumerable: true, get: function () { return index_2.PatternNumberExact; } });
|
|
21
|
-
Object.defineProperty(exports, "PatternString", { enumerable: true, get: function () { return index_2.PatternString; } });
|
|
22
|
-
Object.defineProperty(exports, "PatternStringExact", { enumerable: true, get: function () { return index_2.PatternStringExact; } });
|
|
23
|
-
var index_3 = require("./type/registry/index");
|
|
24
|
-
Object.defineProperty(exports, "TypeRegistry", { enumerable: true, get: function () { return index_3.TypeRegistry; } });
|
|
25
|
-
Object.defineProperty(exports, "FormatRegistry", { enumerable: true, get: function () { return index_3.FormatRegistry; } });
|
|
26
|
-
var index_4 = require("./type/guard/index");
|
|
27
|
-
Object.defineProperty(exports, "TypeGuard", { enumerable: true, get: function () { return index_4.TypeGuard; } });
|
|
28
|
-
Object.defineProperty(exports, "ValueGuard", { enumerable: true, get: function () { return index_4.ValueGuard; } });
|
|
29
|
-
var type_1 = require("./type/clone/type");
|
|
30
|
-
Object.defineProperty(exports, "CloneType", { enumerable: true, get: function () { return type_1.CloneType; } });
|
|
31
|
-
Object.defineProperty(exports, "CloneRest", { enumerable: true, get: function () { return type_1.CloneRest; } });
|
|
32
|
-
// ------------------------------------------------------------------
|
|
33
|
-
// Error
|
|
34
|
-
// ------------------------------------------------------------------
|
|
35
|
-
var index_5 = require("./type/error/index");
|
|
36
|
-
Object.defineProperty(exports, "TypeBoxError", { enumerable: true, get: function () { return index_5.TypeBoxError; } });
|
|
37
|
-
// ------------------------------------------------------------------
|
|
38
|
-
// Sets
|
|
39
|
-
// ------------------------------------------------------------------
|
|
40
|
-
var index_6 = require("./type/sets/index");
|
|
41
|
-
Object.defineProperty(exports, "SetComplement", { enumerable: true, get: function () { return index_6.SetComplement; } });
|
|
42
|
-
Object.defineProperty(exports, "SetDistinct", { enumerable: true, get: function () { return index_6.SetDistinct; } });
|
|
43
|
-
Object.defineProperty(exports, "SetIncludes", { enumerable: true, get: function () { return index_6.SetIncludes; } });
|
|
44
|
-
Object.defineProperty(exports, "SetIntersect", { enumerable: true, get: function () { return index_6.SetIntersect; } });
|
|
45
|
-
Object.defineProperty(exports, "SetIntersectMany", { enumerable: true, get: function () { return index_6.SetIntersectMany; } });
|
|
46
|
-
Object.defineProperty(exports, "SetIsSubset", { enumerable: true, get: function () { return index_6.SetIsSubset; } });
|
|
47
|
-
Object.defineProperty(exports, "SetUnion", { enumerable: true, get: function () { return index_6.SetUnion; } });
|
|
48
|
-
Object.defineProperty(exports, "SetUnionMany", { enumerable: true, get: function () { return index_6.SetUnionMany; } });
|
|
49
|
-
// ------------------------------------------------------------------
|
|
50
|
-
// Helpers
|
|
51
|
-
// ------------------------------------------------------------------
|
|
52
|
-
var index_7 = require("./type/helpers/index");
|
|
53
|
-
Object.defineProperty(exports, "Increment", { enumerable: true, get: function () { return index_7.Increment; } });
|
|
21
|
+
__exportStar(require("./type/clone/index"), exports);
|
|
22
|
+
__exportStar(require("./type/error/index"), exports);
|
|
23
|
+
__exportStar(require("./type/guard/index"), exports);
|
|
24
|
+
__exportStar(require("./type/helpers/index"), exports);
|
|
25
|
+
__exportStar(require("./type/patterns/index"), exports);
|
|
26
|
+
__exportStar(require("./type/registry/index"), exports);
|
|
27
|
+
__exportStar(require("./type/sets/index"), exports);
|
|
28
|
+
__exportStar(require("./type/symbols/index"), exports);
|
|
54
29
|
// ------------------------------------------------------------------
|
|
55
30
|
// Types
|
|
56
31
|
// ------------------------------------------------------------------
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var index_31 = require("./type/keyof/index");
|
|
118
|
-
Object.defineProperty(exports, "KeyOf", { enumerable: true, get: function () { return index_31.KeyOf; } });
|
|
119
|
-
Object.defineProperty(exports, "KeyOfPropertyKeys", { enumerable: true, get: function () { return index_31.KeyOfPropertyKeys; } });
|
|
120
|
-
Object.defineProperty(exports, "KeyOfPropertyKeysToRest", { enumerable: true, get: function () { return index_31.KeyOfPropertyKeysToRest; } });
|
|
121
|
-
Object.defineProperty(exports, "KeyOfFromMappedResult", { enumerable: true, get: function () { return index_31.KeyOfFromMappedResult; } });
|
|
122
|
-
Object.defineProperty(exports, "KeyOfPattern", { enumerable: true, get: function () { return index_31.KeyOfPattern; } });
|
|
123
|
-
var index_32 = require("./type/literal/index");
|
|
124
|
-
Object.defineProperty(exports, "Literal", { enumerable: true, get: function () { return index_32.Literal; } });
|
|
125
|
-
var index_33 = require("./type/mapped/index");
|
|
126
|
-
Object.defineProperty(exports, "Mapped", { enumerable: true, get: function () { return index_33.Mapped; } });
|
|
127
|
-
Object.defineProperty(exports, "MappedKey", { enumerable: true, get: function () { return index_33.MappedKey; } });
|
|
128
|
-
Object.defineProperty(exports, "MappedResult", { enumerable: true, get: function () { return index_33.MappedResult; } });
|
|
129
|
-
Object.defineProperty(exports, "MappedFunctionReturnType", { enumerable: true, get: function () { return index_33.MappedFunctionReturnType; } });
|
|
130
|
-
var index_34 = require("./type/never/index");
|
|
131
|
-
Object.defineProperty(exports, "Never", { enumerable: true, get: function () { return index_34.Never; } });
|
|
132
|
-
var index_35 = require("./type/not/index");
|
|
133
|
-
Object.defineProperty(exports, "Not", { enumerable: true, get: function () { return index_35.Not; } });
|
|
134
|
-
var index_36 = require("./type/null/index");
|
|
135
|
-
Object.defineProperty(exports, "Null", { enumerable: true, get: function () { return index_36.Null; } });
|
|
136
|
-
var index_37 = require("./type/number/index");
|
|
137
|
-
Object.defineProperty(exports, "Number", { enumerable: true, get: function () { return index_37.Number; } });
|
|
138
|
-
var index_38 = require("./type/object/index");
|
|
139
|
-
Object.defineProperty(exports, "Object", { enumerable: true, get: function () { return index_38.Object; } });
|
|
140
|
-
var index_39 = require("./type/omit/index");
|
|
141
|
-
Object.defineProperty(exports, "Omit", { enumerable: true, get: function () { return index_39.Omit; } });
|
|
142
|
-
var index_40 = require("./type/optional/index");
|
|
143
|
-
Object.defineProperty(exports, "Optional", { enumerable: true, get: function () { return index_40.Optional; } });
|
|
144
|
-
Object.defineProperty(exports, "OptionalFromMappedResult", { enumerable: true, get: function () { return index_40.OptionalFromMappedResult; } });
|
|
145
|
-
var index_41 = require("./type/parameters/index");
|
|
146
|
-
Object.defineProperty(exports, "Parameters", { enumerable: true, get: function () { return index_41.Parameters; } });
|
|
147
|
-
var index_42 = require("./type/partial/index");
|
|
148
|
-
Object.defineProperty(exports, "Partial", { enumerable: true, get: function () { return index_42.Partial; } });
|
|
149
|
-
Object.defineProperty(exports, "PartialFromMappedResult", { enumerable: true, get: function () { return index_42.PartialFromMappedResult; } });
|
|
150
|
-
var index_43 = require("./type/pick/index");
|
|
151
|
-
Object.defineProperty(exports, "Pick", { enumerable: true, get: function () { return index_43.Pick; } });
|
|
152
|
-
var index_44 = require("./type/promise/index");
|
|
153
|
-
Object.defineProperty(exports, "Promise", { enumerable: true, get: function () { return index_44.Promise; } });
|
|
154
|
-
var index_45 = require("./type/readonly/index");
|
|
155
|
-
Object.defineProperty(exports, "Readonly", { enumerable: true, get: function () { return index_45.Readonly; } });
|
|
156
|
-
Object.defineProperty(exports, "ReadonlyFromMappedResult", { enumerable: true, get: function () { return index_45.ReadonlyFromMappedResult; } });
|
|
157
|
-
var index_46 = require("./type/readonly-optional/index");
|
|
158
|
-
Object.defineProperty(exports, "ReadonlyOptional", { enumerable: true, get: function () { return index_46.ReadonlyOptional; } });
|
|
159
|
-
var index_47 = require("./type/record/index");
|
|
160
|
-
Object.defineProperty(exports, "Record", { enumerable: true, get: function () { return index_47.Record; } });
|
|
161
|
-
var index_48 = require("./type/recursive/index");
|
|
162
|
-
Object.defineProperty(exports, "Recursive", { enumerable: true, get: function () { return index_48.Recursive; } });
|
|
163
|
-
var index_49 = require("./type/ref/index");
|
|
164
|
-
Object.defineProperty(exports, "Ref", { enumerable: true, get: function () { return index_49.Ref; } });
|
|
165
|
-
var index_50 = require("./type/regexp/index");
|
|
166
|
-
Object.defineProperty(exports, "RegExp", { enumerable: true, get: function () { return index_50.RegExp; } });
|
|
167
|
-
var index_51 = require("./type/required/index");
|
|
168
|
-
Object.defineProperty(exports, "Required", { enumerable: true, get: function () { return index_51.Required; } });
|
|
169
|
-
var index_52 = require("./type/rest/index");
|
|
170
|
-
Object.defineProperty(exports, "Rest", { enumerable: true, get: function () { return index_52.Rest; } });
|
|
171
|
-
var index_53 = require("./type/return-type/index");
|
|
172
|
-
Object.defineProperty(exports, "ReturnType", { enumerable: true, get: function () { return index_53.ReturnType; } });
|
|
173
|
-
var index_54 = require("./type/strict/index");
|
|
174
|
-
Object.defineProperty(exports, "Strict", { enumerable: true, get: function () { return index_54.Strict; } });
|
|
175
|
-
var index_55 = require("./type/string/index");
|
|
176
|
-
Object.defineProperty(exports, "String", { enumerable: true, get: function () { return index_55.String; } });
|
|
177
|
-
var index_56 = require("./type/symbol/index");
|
|
178
|
-
Object.defineProperty(exports, "Symbol", { enumerable: true, get: function () { return index_56.Symbol; } });
|
|
179
|
-
var index_57 = require("./type/template-literal/index");
|
|
180
|
-
Object.defineProperty(exports, "TemplateLiteral", { enumerable: true, get: function () { return index_57.TemplateLiteral; } });
|
|
181
|
-
Object.defineProperty(exports, "TemplateLiteralSyntax", { enumerable: true, get: function () { return index_57.TemplateLiteralSyntax; } });
|
|
182
|
-
Object.defineProperty(exports, "TemplateLiteralGenerate", { enumerable: true, get: function () { return index_57.TemplateLiteralGenerate; } });
|
|
183
|
-
Object.defineProperty(exports, "TemplateLiteralParse", { enumerable: true, get: function () { return index_57.TemplateLiteralParse; } });
|
|
184
|
-
Object.defineProperty(exports, "TemplateLiteralParseExact", { enumerable: true, get: function () { return index_57.TemplateLiteralParseExact; } });
|
|
185
|
-
Object.defineProperty(exports, "TemplateLiteralToUnion", { enumerable: true, get: function () { return index_57.TemplateLiteralToUnion; } });
|
|
186
|
-
Object.defineProperty(exports, "IsTemplateLiteralFinite", { enumerable: true, get: function () { return index_57.IsTemplateLiteralFinite; } });
|
|
187
|
-
Object.defineProperty(exports, "TemplateLiteralExpressionGenerate", { enumerable: true, get: function () { return index_57.TemplateLiteralExpressionGenerate; } });
|
|
188
|
-
Object.defineProperty(exports, "IsTemplateLiteralExpressionFinite", { enumerable: true, get: function () { return index_57.IsTemplateLiteralExpressionFinite; } });
|
|
189
|
-
var index_58 = require("./type/transform/index");
|
|
190
|
-
Object.defineProperty(exports, "Transform", { enumerable: true, get: function () { return index_58.Transform; } });
|
|
191
|
-
Object.defineProperty(exports, "TransformDecodeBuilder", { enumerable: true, get: function () { return index_58.TransformDecodeBuilder; } });
|
|
192
|
-
Object.defineProperty(exports, "TransformEncodeBuilder", { enumerable: true, get: function () { return index_58.TransformEncodeBuilder; } });
|
|
193
|
-
var index_59 = require("./type/tuple/index");
|
|
194
|
-
Object.defineProperty(exports, "Tuple", { enumerable: true, get: function () { return index_59.Tuple; } });
|
|
195
|
-
var index_60 = require("./type/uint8array/index");
|
|
196
|
-
Object.defineProperty(exports, "Uint8Array", { enumerable: true, get: function () { return index_60.Uint8Array; } });
|
|
197
|
-
var index_61 = require("./type/undefined/index");
|
|
198
|
-
Object.defineProperty(exports, "Undefined", { enumerable: true, get: function () { return index_61.Undefined; } });
|
|
199
|
-
var index_62 = require("./type/union/index");
|
|
200
|
-
Object.defineProperty(exports, "Union", { enumerable: true, get: function () { return index_62.Union; } });
|
|
201
|
-
Object.defineProperty(exports, "UnionEvaluated", { enumerable: true, get: function () { return index_62.UnionEvaluated; } });
|
|
202
|
-
var index_63 = require("./type/unknown/index");
|
|
203
|
-
Object.defineProperty(exports, "Unknown", { enumerable: true, get: function () { return index_63.Unknown; } });
|
|
204
|
-
var index_64 = require("./type/unsafe/index");
|
|
205
|
-
Object.defineProperty(exports, "Unsafe", { enumerable: true, get: function () { return index_64.Unsafe; } });
|
|
206
|
-
var index_65 = require("./type/void/index");
|
|
207
|
-
Object.defineProperty(exports, "Void", { enumerable: true, get: function () { return index_65.Void; } });
|
|
32
|
+
__exportStar(require("./type/any/index"), exports);
|
|
33
|
+
__exportStar(require("./type/array/index"), exports);
|
|
34
|
+
__exportStar(require("./type/async-iterator/index"), exports);
|
|
35
|
+
__exportStar(require("./type/awaited/index"), exports);
|
|
36
|
+
__exportStar(require("./type/bigint/index"), exports);
|
|
37
|
+
__exportStar(require("./type/boolean/index"), exports);
|
|
38
|
+
__exportStar(require("./type/composite/index"), exports);
|
|
39
|
+
__exportStar(require("./type/const/index"), exports);
|
|
40
|
+
__exportStar(require("./type/constructor/index"), exports);
|
|
41
|
+
__exportStar(require("./type/constructor-parameters/index"), exports);
|
|
42
|
+
__exportStar(require("./type/date/index"), exports);
|
|
43
|
+
__exportStar(require("./type/deref/index"), exports);
|
|
44
|
+
__exportStar(require("./type/enum/index"), exports);
|
|
45
|
+
__exportStar(require("./type/exclude/index"), exports);
|
|
46
|
+
__exportStar(require("./type/extends/index"), exports);
|
|
47
|
+
__exportStar(require("./type/extract/index"), exports);
|
|
48
|
+
__exportStar(require("./type/function/index"), exports);
|
|
49
|
+
__exportStar(require("./type/indexed/index"), exports);
|
|
50
|
+
__exportStar(require("./type/instance-type/index"), exports);
|
|
51
|
+
__exportStar(require("./type/integer/index"), exports);
|
|
52
|
+
__exportStar(require("./type/intersect/index"), exports);
|
|
53
|
+
__exportStar(require("./type/iterator/index"), exports);
|
|
54
|
+
__exportStar(require("./type/intrinsic/index"), exports);
|
|
55
|
+
__exportStar(require("./type/keyof/index"), exports);
|
|
56
|
+
__exportStar(require("./type/literal/index"), exports);
|
|
57
|
+
__exportStar(require("./type/mapped/index"), exports);
|
|
58
|
+
__exportStar(require("./type/never/index"), exports);
|
|
59
|
+
__exportStar(require("./type/not/index"), exports);
|
|
60
|
+
__exportStar(require("./type/null/index"), exports);
|
|
61
|
+
__exportStar(require("./type/number/index"), exports);
|
|
62
|
+
__exportStar(require("./type/object/index"), exports);
|
|
63
|
+
__exportStar(require("./type/omit/index"), exports);
|
|
64
|
+
__exportStar(require("./type/optional/index"), exports);
|
|
65
|
+
__exportStar(require("./type/parameters/index"), exports);
|
|
66
|
+
__exportStar(require("./type/partial/index"), exports);
|
|
67
|
+
__exportStar(require("./type/pick/index"), exports);
|
|
68
|
+
__exportStar(require("./type/promise/index"), exports);
|
|
69
|
+
__exportStar(require("./type/readonly/index"), exports);
|
|
70
|
+
__exportStar(require("./type/readonly-optional/index"), exports);
|
|
71
|
+
__exportStar(require("./type/record/index"), exports);
|
|
72
|
+
__exportStar(require("./type/recursive/index"), exports);
|
|
73
|
+
__exportStar(require("./type/ref/index"), exports);
|
|
74
|
+
__exportStar(require("./type/regexp/index"), exports);
|
|
75
|
+
__exportStar(require("./type/required/index"), exports);
|
|
76
|
+
__exportStar(require("./type/rest/index"), exports);
|
|
77
|
+
__exportStar(require("./type/return-type/index"), exports);
|
|
78
|
+
__exportStar(require("./type/schema/index"), exports);
|
|
79
|
+
__exportStar(require("./type/static/index"), exports);
|
|
80
|
+
__exportStar(require("./type/strict/index"), exports);
|
|
81
|
+
__exportStar(require("./type/string/index"), exports);
|
|
82
|
+
__exportStar(require("./type/symbol/index"), exports);
|
|
83
|
+
__exportStar(require("./type/template-literal/index"), exports);
|
|
84
|
+
__exportStar(require("./type/transform/index"), exports);
|
|
85
|
+
__exportStar(require("./type/tuple/index"), exports);
|
|
86
|
+
__exportStar(require("./type/uint8array/index"), exports);
|
|
87
|
+
__exportStar(require("./type/undefined/index"), exports);
|
|
88
|
+
__exportStar(require("./type/union/index"), exports);
|
|
89
|
+
__exportStar(require("./type/unknown/index"), exports);
|
|
90
|
+
__exportStar(require("./type/unsafe/index"), exports);
|
|
91
|
+
__exportStar(require("./type/void/index"), exports);
|
|
208
92
|
// ------------------------------------------------------------------
|
|
209
93
|
// Namespace
|
|
210
94
|
// ------------------------------------------------------------------
|
|
211
|
-
|
|
212
|
-
Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return index_66.Type; } });
|
|
213
|
-
Object.defineProperty(exports, "JsonTypeBuilder", { enumerable: true, get: function () { return index_66.JsonTypeBuilder; } });
|
|
214
|
-
Object.defineProperty(exports, "JavaScriptTypeBuilder", { enumerable: true, get: function () { return index_66.JavaScriptTypeBuilder; } });
|
|
95
|
+
__exportStar(require("./type/type/index"), exports);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export *
|
|
2
|
-
export *
|
|
1
|
+
export * from './type';
|
|
2
|
+
export * from './value';
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
3
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.ValueClone = require("./value");
|
|
18
|
+
__exportStar(require("./type"), exports);
|
|
19
|
+
__exportStar(require("./value"), exports);
|
|
@@ -53,6 +53,6 @@ function FromValue(value, root) {
|
|
|
53
53
|
}
|
|
54
54
|
/** `[JavaScript]` Creates a readonly const type from the given value. */
|
|
55
55
|
function Const(T, options = {}) {
|
|
56
|
-
return index_14.
|
|
56
|
+
return (0, index_14.CloneType)(FromValue(T, true), options);
|
|
57
57
|
}
|
|
58
58
|
exports.Const = Const;
|
|
@@ -367,7 +367,9 @@ function IsRegExp(value) {
|
|
|
367
367
|
return (IsKindOf(value, 'RegExp') &&
|
|
368
368
|
IsOptionalString(value.$id) &&
|
|
369
369
|
ValueGuard.IsString(value.source) &&
|
|
370
|
-
ValueGuard.IsString(value.flags)
|
|
370
|
+
ValueGuard.IsString(value.flags) &&
|
|
371
|
+
IsOptionalNumber(value.maxLength) &&
|
|
372
|
+
IsOptionalNumber(value.minLength));
|
|
371
373
|
}
|
|
372
374
|
exports.IsRegExp = IsRegExp;
|
|
373
375
|
/** Returns true if the given value is TString */
|
|
@@ -38,7 +38,7 @@ export interface TObject<T extends TProperties = TProperties> extends TSchema, O
|
|
|
38
38
|
required?: string[];
|
|
39
39
|
}
|
|
40
40
|
/** `[Json]` Creates an Object type */
|
|
41
|
-
|
|
41
|
+
declare function _Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
42
42
|
/** `[Json]` Creates an Object type */
|
|
43
43
|
export declare const Object: typeof _Object;
|
|
44
44
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Object =
|
|
4
|
+
exports.Object = void 0;
|
|
5
5
|
const type_1 = require("../clone/type");
|
|
6
6
|
const index_1 = require("../symbols/index");
|
|
7
7
|
// ------------------------------------------------------------------
|
|
@@ -19,6 +19,5 @@ function _Object(properties, options = {}) {
|
|
|
19
19
|
? { ...options, ...clonedAdditionalProperties, [index_1.Kind]: 'Object', type: 'object', properties: clonedProperties, required: requiredKeys }
|
|
20
20
|
: { ...options, ...clonedAdditionalProperties, [index_1.Kind]: 'Object', type: 'object', properties: clonedProperties });
|
|
21
21
|
}
|
|
22
|
-
exports._Object = _Object;
|
|
23
22
|
/** `[Json]` Creates an Object type */
|
|
24
23
|
exports.Object = _Object;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { SchemaOptions } from '../schema/index';
|
|
2
2
|
import type { TSchema } from '../schema/index';
|
|
3
3
|
import { Kind } from '../symbols/index';
|
|
4
|
+
export interface RegExpOptions extends SchemaOptions {
|
|
5
|
+
/** The maximum length of the string */
|
|
6
|
+
maxLength?: number;
|
|
7
|
+
/** The minimum length of the string */
|
|
8
|
+
minLength?: number;
|
|
9
|
+
}
|
|
4
10
|
export interface TRegExp extends TSchema {
|
|
5
11
|
[Kind]: 'RegExp';
|
|
6
12
|
static: `${string}`;
|
|
@@ -9,6 +15,6 @@ export interface TRegExp extends TSchema {
|
|
|
9
15
|
flags: string;
|
|
10
16
|
}
|
|
11
17
|
/** `[JavaScript]` Creates a RegExp type */
|
|
12
|
-
export declare function RegExp(pattern: string, options?:
|
|
18
|
+
export declare function RegExp(pattern: string, options?: RegExpOptions): TRegExp;
|
|
13
19
|
/** `[JavaScript]` Creates a RegExp type */
|
|
14
|
-
export declare function RegExp(regex: RegExp, options?:
|
|
20
|
+
export declare function RegExp(regex: RegExp, options?: RegExpOptions): TRegExp;
|
|
@@ -10,7 +10,7 @@ import { type TInstanceType } from '../instance-type/index';
|
|
|
10
10
|
import { type TIterator } from '../iterator/index';
|
|
11
11
|
import { type TParameters } from '../parameters/index';
|
|
12
12
|
import { type TPromise } from '../promise/index';
|
|
13
|
-
import { type TRegExp } from '../regexp/index';
|
|
13
|
+
import { type TRegExp, RegExpOptions } from '../regexp/index';
|
|
14
14
|
import { type TReturnType } from '../return-type/index';
|
|
15
15
|
import { type TSchema, type SchemaOptions } from '../schema/index';
|
|
16
16
|
import { type TSymbol } from '../symbol/index';
|
|
@@ -42,9 +42,9 @@ export declare class JavaScriptTypeBuilder extends JsonTypeBuilder {
|
|
|
42
42
|
/** `[JavaScript]` Creates a Promise type */
|
|
43
43
|
Promise<T extends TSchema>(item: T, options?: SchemaOptions): TPromise<T>;
|
|
44
44
|
/** `[JavaScript]` Creates a RegExp type */
|
|
45
|
-
RegExp(pattern: string, options?:
|
|
45
|
+
RegExp(pattern: string, options?: RegExpOptions): TRegExp;
|
|
46
46
|
/** `[JavaScript]` Creates a RegExp type */
|
|
47
|
-
RegExp(regex: RegExp, options?:
|
|
47
|
+
RegExp(regex: RegExp, options?: RegExpOptions): TRegExp;
|
|
48
48
|
/** `[JavaScript]` Extracts the ReturnType from the given Function type */
|
|
49
49
|
ReturnType<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TReturnType<T>;
|
|
50
50
|
/** `[JavaScript]` Creates a Symbol type */
|
|
@@ -291,6 +291,14 @@ function FromRef(schema, references, value) {
|
|
|
291
291
|
}
|
|
292
292
|
function FromRegExp(schema, references, value) {
|
|
293
293
|
const regex = new RegExp(schema.source, schema.flags);
|
|
294
|
+
if (IsDefined(schema.minLength)) {
|
|
295
|
+
if (!(value.length >= schema.minLength))
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
if (IsDefined(schema.maxLength)) {
|
|
299
|
+
if (!(value.length <= schema.maxLength))
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
294
302
|
return regex.test(value);
|
|
295
303
|
}
|
|
296
304
|
function FromString(schema, references, value) {
|