arktype 0.1.3 → 0.2.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.
Files changed (74) hide show
  1. package/README.md +1 -1
  2. package/dist/api.cjs +4 -3
  3. package/dist/api.d.ts +3 -2
  4. package/dist/api.mjs +2 -1
  5. package/dist/cjs/nodes/node.js +20 -2
  6. package/dist/cjs/nodes/predicate.js +2 -0
  7. package/dist/cjs/nodes/rules/regex.js +4 -42
  8. package/dist/cjs/nodes/rules/rules.js +16 -12
  9. package/dist/cjs/parse/definition.js +2 -2
  10. package/dist/cjs/parse/string/ast.js +1 -1
  11. package/dist/cjs/parse/tuple/keyof.js +6 -7
  12. package/dist/cjs/parse/tuple/morph.js +7 -6
  13. package/dist/cjs/scopes/cache.js +39 -0
  14. package/dist/cjs/scopes/jsObjects.js +133 -0
  15. package/dist/cjs/scopes/scope.js +244 -0
  16. package/dist/cjs/scopes/standard.js +44 -0
  17. package/dist/cjs/scopes/tsKeywords.js +113 -0
  18. package/dist/cjs/scopes/type.js +70 -0
  19. package/dist/cjs/scopes/validation.js +64 -0
  20. package/dist/cjs/traverse/problems.js +50 -74
  21. package/dist/cjs/traverse/traverse.js +25 -3
  22. package/dist/cjs/utils/numericLiterals.js +1 -0
  23. package/dist/mjs/nodes/node.js +20 -2
  24. package/dist/mjs/nodes/predicate.js +1 -0
  25. package/dist/mjs/nodes/rules/regex.js +3 -41
  26. package/dist/mjs/nodes/rules/rules.js +17 -13
  27. package/dist/mjs/parse/definition.js +1 -1
  28. package/dist/mjs/parse/string/ast.js +1 -1
  29. package/dist/mjs/parse/tuple/keyof.js +6 -7
  30. package/dist/mjs/parse/tuple/morph.js +7 -6
  31. package/dist/mjs/scopes/cache.js +25 -0
  32. package/dist/mjs/scopes/jsObjects.js +119 -0
  33. package/dist/mjs/{main.js → scopes/scope.js} +23 -349
  34. package/dist/mjs/scopes/standard.js +27 -0
  35. package/dist/mjs/scopes/tsKeywords.js +99 -0
  36. package/dist/mjs/scopes/type.js +56 -0
  37. package/dist/mjs/scopes/validation.js +51 -0
  38. package/dist/mjs/traverse/problems.js +49 -73
  39. package/dist/mjs/traverse/traverse.js +26 -4
  40. package/dist/mjs/utils/numericLiterals.js +1 -1
  41. package/dist/tsconfig.temp.tsbuildinfo +1 -1
  42. package/dist/types/nodes/compose.d.ts +1 -1
  43. package/dist/types/nodes/infer.d.ts +4 -4
  44. package/dist/types/nodes/node.d.ts +11 -7
  45. package/dist/types/nodes/predicate.d.ts +43 -54
  46. package/dist/types/nodes/rules/range.d.ts +1 -1
  47. package/dist/types/nodes/rules/regex.d.ts +1 -11
  48. package/dist/types/nodes/rules/rules.d.ts +2 -10
  49. package/dist/types/parse/definition.d.ts +1 -1
  50. package/dist/types/parse/record.d.ts +2 -2
  51. package/dist/types/parse/string/ast.d.ts +5 -4
  52. package/dist/types/parse/string/reduce/dynamic.d.ts +1 -1
  53. package/dist/types/parse/string/reduce/shared.d.ts +1 -1
  54. package/dist/types/parse/string/reduce/static.d.ts +1 -1
  55. package/dist/types/parse/string/shift/operand/unenclosed.d.ts +1 -1
  56. package/dist/types/parse/string/shift/operator/bounds.d.ts +1 -1
  57. package/dist/types/parse/tuple/keyof.d.ts +8 -0
  58. package/dist/types/parse/tuple/morph.d.ts +1 -1
  59. package/dist/types/parse/tuple/narrow.d.ts +1 -1
  60. package/dist/types/parse/tuple/tuple.d.ts +7 -13
  61. package/dist/types/scopes/cache.d.ts +14 -0
  62. package/dist/types/scopes/jsObjects.d.ts +36 -0
  63. package/dist/types/scopes/scope.d.ts +76 -0
  64. package/dist/types/scopes/standard.d.ts +280 -0
  65. package/dist/types/scopes/tsKeywords.d.ts +32 -0
  66. package/dist/types/scopes/type.d.ts +53 -0
  67. package/dist/types/scopes/validation.d.ts +21 -0
  68. package/dist/types/traverse/problems.d.ts +29 -32
  69. package/dist/types/traverse/traverse.d.ts +10 -8
  70. package/dist/types/utils/generics.d.ts +2 -1
  71. package/dist/types/utils/numericLiterals.d.ts +1 -0
  72. package/package.json +2 -2
  73. package/dist/cjs/main.js +0 -574
  74. package/dist/types/main.d.ts +0 -321
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ Scope: ()=>Scope,
13
+ writeShallowCycleErrorMessage: ()=>writeShallowCycleErrorMessage,
14
+ scope: ()=>scope,
15
+ writeDuplicateAliasesMessage: ()=>writeDuplicateAliasesMessage
16
+ });
17
+ const _nodeTs = require("../nodes/node.js");
18
+ const _definitionTs = require("../parse/definition.js");
19
+ const _chainableNoOpProxyTs = require("../utils/chainableNoOpProxy.js");
20
+ const _errorsTs = require("../utils/errors.js");
21
+ const _pathsTs = require("../utils/paths.js");
22
+ const _cacheTs = require("./cache.js");
23
+ const _typeTs = require("./type.js");
24
+ function _checkPrivateRedeclaration(obj, privateCollection) {
25
+ if (privateCollection.has(obj)) {
26
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
27
+ }
28
+ }
29
+ function _classApplyDescriptorGet(receiver, descriptor) {
30
+ if (descriptor.get) {
31
+ return descriptor.get.call(receiver);
32
+ }
33
+ return descriptor.value;
34
+ }
35
+ function _classApplyDescriptorSet(receiver, descriptor, value) {
36
+ if (descriptor.set) {
37
+ descriptor.set.call(receiver, value);
38
+ } else {
39
+ if (!descriptor.writable) {
40
+ throw new TypeError("attempted to set read only private field");
41
+ }
42
+ descriptor.value = value;
43
+ }
44
+ }
45
+ function _classApplyDescriptorUpdate(receiver, descriptor) {
46
+ if (descriptor.set) {
47
+ if (!descriptor.get) {
48
+ throw new TypeError("attempted to read set only private field");
49
+ }
50
+ if (!("__destrWrapper" in descriptor)) {
51
+ descriptor.__destrWrapper = {
52
+ set value (v){
53
+ descriptor.set.call(receiver, v);
54
+ },
55
+ get value () {
56
+ return descriptor.get.call(receiver);
57
+ }
58
+ };
59
+ }
60
+ return descriptor.__destrWrapper;
61
+ } else {
62
+ if (!descriptor.writable) {
63
+ throw new TypeError("attempted to set read only private field");
64
+ }
65
+ return descriptor;
66
+ }
67
+ }
68
+ function _classExtractFieldDescriptor(receiver, privateMap, action) {
69
+ if (!privateMap.has(receiver)) {
70
+ throw new TypeError("attempted to " + action + " private field on non-instance");
71
+ }
72
+ return privateMap.get(receiver);
73
+ }
74
+ function _classPrivateFieldGet(receiver, privateMap) {
75
+ var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
76
+ return _classApplyDescriptorGet(receiver, descriptor);
77
+ }
78
+ function _classPrivateFieldInit(obj, privateMap, value) {
79
+ _checkPrivateRedeclaration(obj, privateMap);
80
+ privateMap.set(obj, value);
81
+ }
82
+ function _classPrivateFieldSet(receiver, privateMap, value) {
83
+ var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
84
+ _classApplyDescriptorSet(receiver, descriptor, value);
85
+ return value;
86
+ }
87
+ function _classPrivateFieldUpdate(receiver, privateMap) {
88
+ var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "update");
89
+ return _classApplyDescriptorUpdate(receiver, descriptor);
90
+ }
91
+ function _classPrivateMethodGet(receiver, privateSet, fn) {
92
+ if (!privateSet.has(receiver)) {
93
+ throw new TypeError("attempted to get private field on non-instance");
94
+ }
95
+ return fn;
96
+ }
97
+ function _classPrivateMethodInit(obj, privateSet) {
98
+ _checkPrivateRedeclaration(obj, privateSet);
99
+ privateSet.add(obj);
100
+ }
101
+ var _ctx_type_meta;
102
+ let anonymousScopeCount = 0;
103
+ const scopeRegistry = {};
104
+ const spaceRegistry = {};
105
+ var _resolutions = /*#__PURE__*/ new WeakMap(), _exports = /*#__PURE__*/ new WeakMap(), _anonymousTypeCount = /*#__PURE__*/ new WeakMap(), _register = /*#__PURE__*/ new WeakSet(), _cacheSpaces = /*#__PURE__*/ new WeakSet(), _initializeContext = /*#__PURE__*/ new WeakSet(), _resolveRecurse = /*#__PURE__*/ new WeakSet();
106
+ class Scope {
107
+ createAnonymousTypeSuffix() {
108
+ return ++_classPrivateFieldUpdate(this, _anonymousTypeCount).value;
109
+ }
110
+ get infer() {
111
+ return _chainableNoOpProxyTs.chainableNoOpProxy;
112
+ }
113
+ compile() {
114
+ if (!spaceRegistry[this.name]) {
115
+ for(const name in this.aliases){
116
+ this.resolve(name);
117
+ }
118
+ spaceRegistry[this.name] = _classPrivateFieldGet(this, _exports).root;
119
+ }
120
+ return _classPrivateFieldGet(this, _exports).root;
121
+ }
122
+ addReferenceIfResolvable(name, ctx) {
123
+ const resolution = _classPrivateMethodGet(this, _resolveRecurse, resolveRecurse).call(this, name, "undefined", []);
124
+ if (!resolution) {
125
+ return false;
126
+ }
127
+ (_ctx_type_meta = ctx.type.meta).includesMorph || (_ctx_type_meta.includesMorph = resolution.meta.includesMorph);
128
+ return true;
129
+ }
130
+ resolve(name) {
131
+ return _classPrivateMethodGet(this, _resolveRecurse, resolveRecurse).call(this, name, "throw", []);
132
+ }
133
+ resolveNode(node) {
134
+ if (typeof node === "object") {
135
+ return node;
136
+ }
137
+ return this.resolveNode(this.resolve(node).node);
138
+ }
139
+ constructor(aliases, opts){
140
+ _classPrivateMethodInit(this, _register);
141
+ _classPrivateMethodInit(this, _cacheSpaces);
142
+ _classPrivateMethodInit(this, _initializeContext);
143
+ _classPrivateMethodInit(this, _resolveRecurse);
144
+ _classPrivateFieldInit(this, _resolutions, {
145
+ writable: true,
146
+ value: void 0
147
+ });
148
+ _classPrivateFieldInit(this, _exports, {
149
+ writable: true,
150
+ value: void 0
151
+ });
152
+ _classPrivateFieldInit(this, _anonymousTypeCount, {
153
+ writable: true,
154
+ value: void 0
155
+ });
156
+ this.aliases = aliases;
157
+ this.opts = opts;
158
+ this.parseCache = new _cacheTs.FreezingCache();
159
+ _classPrivateFieldSet(this, _resolutions, new _cacheTs.Cache());
160
+ _classPrivateFieldSet(this, _exports, new _cacheTs.Cache());
161
+ _classPrivateFieldSet(this, _anonymousTypeCount, 0);
162
+ this.type = (def, opts = {})=>{
163
+ if (opts.name && this.aliases[opts.name]) {
164
+ return (0, _errorsTs.throwParseError)(writeDuplicateAliasesMessage(opts.name));
165
+ }
166
+ const result = (0, _typeTs.initializeType)(def, opts, this);
167
+ const ctx = _classPrivateMethodGet(this, _initializeContext, initializeContext).call(this, result);
168
+ result.node = this.resolveNode((0, _definitionTs.parseDefinition)(def, ctx));
169
+ result.flat = (0, _nodeTs.flattenType)(result);
170
+ return result;
171
+ };
172
+ this.name = _classPrivateMethodGet(this, _register, register).call(this, opts);
173
+ if (opts.standard !== false) {
174
+ _classPrivateMethodGet(this, _cacheSpaces, cacheSpaces).call(this, [
175
+ spaceRegistry["standard"]
176
+ ], "imports");
177
+ }
178
+ if (opts.imports) {
179
+ _classPrivateMethodGet(this, _cacheSpaces, cacheSpaces).call(this, opts.imports, "imports");
180
+ }
181
+ if (opts.includes) {
182
+ _classPrivateMethodGet(this, _cacheSpaces, cacheSpaces).call(this, opts.includes, "includes");
183
+ }
184
+ if (opts.config) {
185
+ this.config = opts.config;
186
+ }
187
+ }
188
+ }
189
+ function register(opts) {
190
+ const name = opts.name ? scopeRegistry[opts.name] ? (0, _errorsTs.throwParseError)(`A scope named '${opts.name}' already exists`) : opts.name : `scope${++anonymousScopeCount}`;
191
+ scopeRegistry[name] = this;
192
+ return name;
193
+ }
194
+ function cacheSpaces(spaces, kind) {
195
+ for (const space of spaces){
196
+ for(const name in space){
197
+ if (_classPrivateFieldGet(this, _resolutions).has(name) || name in this.aliases) {
198
+ (0, _errorsTs.throwParseError)(writeDuplicateAliasesMessage(name));
199
+ }
200
+ _classPrivateFieldGet(this, _resolutions).set(name, space[name]);
201
+ if (kind === "includes") {
202
+ _classPrivateFieldGet(this, _exports).set(name, space[name]);
203
+ }
204
+ }
205
+ }
206
+ }
207
+ function initializeContext(type) {
208
+ return {
209
+ type,
210
+ path: new _pathsTs.Path()
211
+ };
212
+ }
213
+ function resolveRecurse(name, onUnresolvable, seen) {
214
+ const maybeCacheResult = _classPrivateFieldGet(this, _resolutions).get(name);
215
+ if (maybeCacheResult) {
216
+ return maybeCacheResult;
217
+ }
218
+ if (!this.aliases[name]) {
219
+ return onUnresolvable === "throw" ? (0, _errorsTs.throwInternalError)(`Unexpectedly failed to resolve alias '${name}'`) : undefined;
220
+ }
221
+ const type = (0, _typeTs.initializeType)(this.aliases[name], {
222
+ name
223
+ }, this);
224
+ _classPrivateFieldGet(this, _resolutions).set(name, type);
225
+ _classPrivateFieldGet(this, _exports).set(name, type);
226
+ const ctx = _classPrivateMethodGet(this, _initializeContext, initializeContext).call(this, type);
227
+ let resolution = (0, _definitionTs.parseDefinition)(type.meta.definition, ctx);
228
+ if (typeof resolution === "string") {
229
+ if (seen.includes(resolution)) {
230
+ return (0, _errorsTs.throwParseError)(writeShallowCycleErrorMessage(name, seen));
231
+ }
232
+ seen.push(resolution);
233
+ resolution = _classPrivateMethodGet(this, _resolveRecurse, resolveRecurse).call(this, resolution, "throw", seen).node;
234
+ }
235
+ type.node = resolution;
236
+ type.flat = (0, _nodeTs.flattenType)(type);
237
+ return type;
238
+ }
239
+ const writeShallowCycleErrorMessage = (name, seen)=>`Alias '${name}' has a shallow resolution cycle: ${[
240
+ ...seen,
241
+ name
242
+ ].join("=>")}`;
243
+ const scope = (aliases, opts = {})=>new Scope(aliases, opts);
244
+ const writeDuplicateAliasesMessage = (name)=>`Alias '${name}' is already defined`;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ standardScope: ()=>standardScope,
13
+ standard: ()=>standard,
14
+ scopes: ()=>scopes,
15
+ spaces: ()=>spaces,
16
+ type: ()=>type
17
+ });
18
+ const _jsObjectsTs = require("./jsObjects.js");
19
+ const _scopeTs = require("./scope.js");
20
+ const _tsKeywordsTs = require("./tsKeywords.js");
21
+ const _validationTs = require("./validation.js");
22
+ const standardScope = (0, _scopeTs.scope)({}, {
23
+ name: "standard",
24
+ includes: [
25
+ _tsKeywordsTs.tsKeywords,
26
+ _jsObjectsTs.jsObjects,
27
+ _validationTs.validation
28
+ ],
29
+ standard: false
30
+ });
31
+ const standard = standardScope.compile();
32
+ const scopes = {
33
+ tsKeywords: _tsKeywordsTs.tsKeywordsScope,
34
+ jsObjects: _jsObjectsTs.jsObjectsScope,
35
+ validation: _validationTs.validationScope,
36
+ standard: standardScope
37
+ };
38
+ const spaces = {
39
+ tsKeywords: _tsKeywordsTs.tsKeywords,
40
+ jsObjects: _jsObjectsTs.jsObjects,
41
+ validation: _validationTs.validation,
42
+ standard
43
+ };
44
+ const type = scopes.standard.type;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ tsKeywordsScope: ()=>tsKeywordsScope,
13
+ tsKeywords: ()=>tsKeywords
14
+ });
15
+ const _scopeTs = require("./scope.js");
16
+ const always = {
17
+ bigint: true,
18
+ boolean: true,
19
+ null: true,
20
+ number: true,
21
+ object: true,
22
+ string: true,
23
+ symbol: true,
24
+ undefined: true
25
+ };
26
+ const tsKeywordsScope = (0, _scopeTs.scope)({
27
+ any: [
28
+ "node",
29
+ always
30
+ ],
31
+ bigint: [
32
+ "node",
33
+ {
34
+ bigint: true
35
+ }
36
+ ],
37
+ boolean: [
38
+ "node",
39
+ {
40
+ boolean: true
41
+ }
42
+ ],
43
+ false: [
44
+ "node",
45
+ {
46
+ boolean: {
47
+ value: false
48
+ }
49
+ }
50
+ ],
51
+ never: [
52
+ "node",
53
+ {}
54
+ ],
55
+ null: [
56
+ "node",
57
+ {
58
+ null: true
59
+ }
60
+ ],
61
+ number: [
62
+ "node",
63
+ {
64
+ number: true
65
+ }
66
+ ],
67
+ object: [
68
+ "node",
69
+ {
70
+ object: true
71
+ }
72
+ ],
73
+ string: [
74
+ "node",
75
+ {
76
+ string: true
77
+ }
78
+ ],
79
+ symbol: [
80
+ "node",
81
+ {
82
+ symbol: true
83
+ }
84
+ ],
85
+ true: [
86
+ "node",
87
+ {
88
+ boolean: {
89
+ value: true
90
+ }
91
+ }
92
+ ],
93
+ unknown: [
94
+ "node",
95
+ always
96
+ ],
97
+ void: [
98
+ "node",
99
+ {
100
+ undefined: true
101
+ }
102
+ ],
103
+ undefined: [
104
+ "node",
105
+ {
106
+ undefined: true
107
+ }
108
+ ]
109
+ }, {
110
+ name: "ts",
111
+ standard: false
112
+ });
113
+ const tsKeywords = tsKeywordsScope.compile();
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ initializeType: ()=>initializeType,
13
+ isType: ()=>isType
14
+ });
15
+ const _traverseTs = require("../traverse/traverse.js");
16
+ const _chainableNoOpProxyTs = require("../utils/chainableNoOpProxy.js");
17
+ const _genericsTs = require("../utils/generics.js");
18
+ const compileTypeConfig = (opts)=>{
19
+ if (opts === undefined) {
20
+ return;
21
+ }
22
+ const { name , ...config } = opts;
23
+ if ((0, _genericsTs.hasKeys)(config)) {
24
+ return config;
25
+ }
26
+ };
27
+ const initializeType = (definition, opts, scope)=>{
28
+ const name = opts?.name ?? "type";
29
+ const config = compileTypeConfig(opts);
30
+ const meta = {
31
+ name,
32
+ id: `${scope.name}.${opts?.name ? name : `type${scope.createAnonymousTypeSuffix()}`}`,
33
+ definition,
34
+ scope,
35
+ config,
36
+ includesMorph: false
37
+ };
38
+ const root = {
39
+ // temporarily initialize node/flat to aliases that will be included in
40
+ // the final type in case of cyclic resolutions
41
+ node: name,
42
+ flat: [
43
+ [
44
+ "alias",
45
+ name
46
+ ]
47
+ ],
48
+ meta,
49
+ infer: _chainableNoOpProxyTs.chainableNoOpProxy
50
+ };
51
+ // dynamically assign a name to the primary traversal function
52
+ const namedTraverse = {
53
+ [name]: (data)=>{
54
+ const state = new _traverseTs.TraversalState(type);
55
+ const out = (0, _traverseTs.traverse)(data, type.flat, state);
56
+ return state.problems.length ? {
57
+ data,
58
+ problems: state.problems
59
+ } : {
60
+ data,
61
+ out
62
+ };
63
+ }
64
+ }[name];
65
+ // we need to assign this to a variable before returning so we can reference
66
+ // it in namedTraverse
67
+ const type = Object.assign(namedTraverse, root);
68
+ return type;
69
+ };
70
+ const isType = (value)=>value?.infer === _chainableNoOpProxyTs.chainableNoOpProxy;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ isLuhnValid: ()=>isLuhnValid,
13
+ validationScope: ()=>validationScope,
14
+ validation: ()=>validation
15
+ });
16
+ const _scopeTs = require("./scope.js");
17
+ const isLuhnValid = (creditCardInput)=>{
18
+ const sanitized = creditCardInput.replace(/[- ]+/g, "");
19
+ let sum = 0;
20
+ let digit;
21
+ let tmpNum;
22
+ let shouldDouble;
23
+ for(let i = sanitized.length - 1; i >= 0; i--){
24
+ digit = sanitized.substring(i, i + 1);
25
+ tmpNum = parseInt(digit, 10);
26
+ if (shouldDouble) {
27
+ tmpNum *= 2;
28
+ if (tmpNum >= 10) {
29
+ sum += tmpNum % 10 + 1;
30
+ } else {
31
+ sum += tmpNum;
32
+ }
33
+ } else {
34
+ sum += tmpNum;
35
+ }
36
+ shouldDouble = !shouldDouble;
37
+ }
38
+ return !!(sum % 10 === 0 ? sanitized : false);
39
+ };
40
+ const validationScope = (0, _scopeTs.scope)({
41
+ // Character sets
42
+ alpha: /^[A-Za-z]*$/,
43
+ alphanumeric: /^[A-Za-z\d]*$/,
44
+ lowercase: /^[a-z]*$/,
45
+ uppercase: /^[A-Z]*$/,
46
+ // https://github.com/validatorjs/validator.js
47
+ creditCard: /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
48
+ // https://www.regular-expressions.info
49
+ email: /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/,
50
+ // https://github.com/validatorjs/validator.js
51
+ uuid: /^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/,
52
+ integer: [
53
+ "node",
54
+ {
55
+ number: {
56
+ divisor: 1
57
+ }
58
+ }
59
+ ]
60
+ }, {
61
+ name: "validation",
62
+ standard: false
63
+ });
64
+ const validation = validationScope.compile();