@oxog/vld 2.1.0 → 2.2.7
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/CHANGELOG.md +113 -0
- package/README.md +413 -1235
- package/dist/chunks/errors-core-CerMg2rq.js +1 -0
- package/dist/chunks/index-CkbfQQ4n.js +1 -0
- package/dist/chunks/index-yjpbvFgw.js +1 -0
- package/dist/chunks/ip-validation-g5LWgy9t.js +1 -0
- package/dist/chunks/security-Dy24T8N7.js +1 -0
- package/dist/cjs/chunks/errors-core-DrydF46s.cjs +1 -0
- package/dist/cjs/chunks/index-BEV9nG0N.cjs +1 -0
- package/dist/cjs/chunks/index-ZjHAxYdA.cjs +1 -0
- package/dist/cjs/chunks/ip-validation-BZqPamPC.cjs +1 -0
- package/dist/cjs/chunks/security-aXZVI7qW.cjs +1 -0
- package/dist/cjs/cli/bin.cjs +1 -505
- package/dist/cjs/cli/index.cjs +1 -209
- package/dist/cjs/codecs/index.cjs +1 -45
- package/dist/cjs/coercion/index.cjs +1 -588
- package/dist/cjs/compat/emitter.cjs +1 -184
- package/dist/cjs/compat/result.cjs +1 -189
- package/dist/cjs/errors.cjs +1 -180
- package/dist/cjs/index.cjs +1 -1894
- package/dist/cjs/kernel.cjs +1 -415
- package/dist/cjs/locales/af.cjs +1 -108
- package/dist/cjs/locales/ar.cjs +1 -108
- package/dist/cjs/locales/bn.cjs +1 -108
- package/dist/cjs/locales/da.cjs +1 -108
- package/dist/cjs/locales/de.cjs +1 -108
- package/dist/cjs/locales/en.cjs +1 -108
- package/dist/cjs/locales/es-MX.cjs +1 -107
- package/dist/cjs/locales/es.cjs +1 -96
- package/dist/cjs/locales/fi.cjs +1 -108
- package/dist/cjs/locales/fr.cjs +1 -96
- package/dist/cjs/locales/hi.cjs +1 -108
- package/dist/cjs/locales/id.cjs +1 -108
- package/dist/cjs/locales/index.cjs +1 -43
- package/dist/cjs/locales/it.cjs +1 -108
- package/dist/cjs/locales/ja.cjs +1 -108
- package/dist/cjs/locales/ko.cjs +1 -108
- package/dist/cjs/locales/lazy.cjs +1 -188
- package/dist/cjs/locales/nl.cjs +1 -108
- package/dist/cjs/locales/no.cjs +1 -108
- package/dist/cjs/locales/pl.cjs +1 -108
- package/dist/cjs/locales/pt-BR.cjs +1 -108
- package/dist/cjs/locales/pt.cjs +1 -108
- package/dist/cjs/locales/ru.cjs +1 -108
- package/dist/cjs/locales/runtime.cjs +1 -51
- package/dist/cjs/locales/sv.cjs +1 -108
- package/dist/cjs/locales/sw.cjs +1 -108
- package/dist/cjs/locales/th.cjs +1 -108
- package/dist/cjs/locales/tr.cjs +1 -108
- package/dist/cjs/locales/vi.cjs +1 -108
- package/dist/cjs/locales/zh.cjs +1 -108
- package/dist/cjs/mini.cjs +1 -242
- package/dist/cjs/pigment.cjs +1 -207
- package/dist/cjs/plugins/index.cjs +1 -12
- package/dist/cjs/registry.cjs +1 -37
- package/dist/cjs/v3/index.cjs +1 -425
- package/dist/cjs/v4/core/index.cjs +1 -894
- package/dist/cjs/v4/index.cjs +1 -425
- package/dist/cjs/v4/locales/index.cjs +1 -130
- package/dist/cjs/v4/mini/index.cjs +1 -509
- package/dist/cjs/v4-mini/index.cjs +1 -532
- package/dist/cjs/validators/any.cjs +1 -40
- package/dist/cjs/validators/array.cjs +1 -283
- package/dist/cjs/validators/base.cjs +1 -887
- package/dist/cjs/validators/base64.cjs +1 -73
- package/dist/cjs/validators/bigint.cjs +1 -232
- package/dist/cjs/validators/boolean.cjs +1 -146
- package/dist/cjs/validators/codec.cjs +1 -205
- package/dist/cjs/validators/custom.cjs +1 -71
- package/dist/cjs/validators/date.cjs +1 -278
- package/dist/cjs/validators/discriminated-union.cjs +1 -130
- package/dist/cjs/validators/enum.cjs +1 -154
- package/dist/cjs/validators/file.cjs +1 -130
- package/dist/cjs/validators/function.cjs +1 -63
- package/dist/cjs/validators/hex.cjs +1 -70
- package/dist/cjs/validators/index.cjs +1 -123
- package/dist/cjs/validators/intersection.cjs +1 -120
- package/dist/cjs/validators/json.cjs +1 -70
- package/dist/cjs/validators/lazy.cjs +1 -53
- package/dist/cjs/validators/literal.cjs +1 -64
- package/dist/cjs/validators/map.cjs +1 -218
- package/dist/cjs/validators/nan.cjs +1 -41
- package/dist/cjs/validators/never.cjs +1 -36
- package/dist/cjs/validators/null.cjs +1 -43
- package/dist/cjs/validators/number.cjs +1 -427
- package/dist/cjs/validators/object.cjs +1 -868
- package/dist/cjs/validators/promise.cjs +1 -115
- package/dist/cjs/validators/record.cjs +1 -262
- package/dist/cjs/validators/set.cjs +1 -203
- package/dist/cjs/validators/string-bool.cjs +1 -124
- package/dist/cjs/validators/string-formats.cjs +1 -168
- package/dist/cjs/validators/string.cjs +1 -12
- package/dist/cjs/validators/symbol.cjs +1 -62
- package/dist/cjs/validators/template-literal.cjs +1 -108
- package/dist/cjs/validators/tuple.cjs +1 -187
- package/dist/cjs/validators/uint8array.cjs +1 -106
- package/dist/cjs/validators/undefined.cjs +1 -43
- package/dist/cjs/validators/union.cjs +1 -191
- package/dist/cjs/validators/unknown.cjs +1 -40
- package/dist/cjs/validators/void.cjs +1 -48
- package/dist/cjs/validators/xor.cjs +1 -69
- package/dist/cli/bin.js +1 -406
- package/dist/cli/index.js +1 -205
- package/dist/codecs/index.js +1 -11
- package/dist/coercion/index.js +1 -579
- package/dist/compat/emitter.js +1 -180
- package/dist/compat/result.js +1 -170
- package/dist/errors-core.d.ts +32 -2
- package/dist/errors.js +1 -171
- package/dist/index.d.ts +315 -361
- package/dist/index.js +1 -1534
- package/dist/kernel.js +1 -409
- package/dist/locales/af.js +1 -106
- package/dist/locales/ar.js +1 -106
- package/dist/locales/bn.js +1 -106
- package/dist/locales/da.js +1 -106
- package/dist/locales/de.js +1 -106
- package/dist/locales/en.js +1 -106
- package/dist/locales/es-MX.js +1 -105
- package/dist/locales/es.js +1 -94
- package/dist/locales/fi.js +1 -106
- package/dist/locales/fr.js +1 -94
- package/dist/locales/hi.js +1 -106
- package/dist/locales/id.js +1 -106
- package/dist/locales/index.js +1 -29
- package/dist/locales/it.js +1 -106
- package/dist/locales/ja.js +1 -106
- package/dist/locales/ko.js +1 -106
- package/dist/locales/lazy.js +1 -177
- package/dist/locales/nl.js +1 -106
- package/dist/locales/no.js +1 -106
- package/dist/locales/pl.js +1 -106
- package/dist/locales/pt-BR.js +1 -106
- package/dist/locales/pt.js +1 -106
- package/dist/locales/ru.js +1 -106
- package/dist/locales/runtime.js +1 -41
- package/dist/locales/sv.js +1 -106
- package/dist/locales/sw.js +1 -106
- package/dist/locales/th.js +1 -106
- package/dist/locales/tr.js +1 -106
- package/dist/locales/vi.js +1 -106
- package/dist/locales/zh.js +1 -106
- package/dist/mini.d.ts +3 -3
- package/dist/mini.js +1 -156
- package/dist/pigment.js +1 -180
- package/dist/plugins/index.js +1 -1
- package/dist/registry.js +1 -34
- package/dist/utils/json-schema.d.ts +10 -1
- package/dist/v3/index.js +1 -46
- package/dist/v4/core/index.d.ts +28 -16
- package/dist/v4/core/index.js +1 -277
- package/dist/v4/index.js +1 -50
- package/dist/v4/locales/index.d.ts +4 -0
- package/dist/v4/locales/index.js +1 -77
- package/dist/v4/mini/index.js +1 -47
- package/dist/v4-mini/index.d.ts +1 -1
- package/dist/v4-mini/index.js +1 -75
- package/dist/validators/any.js +1 -37
- package/dist/validators/array.d.ts +7 -0
- package/dist/validators/array.js +1 -279
- package/dist/validators/base.d.ts +210 -17
- package/dist/validators/base.js +1 -868
- package/dist/validators/base64.js +1 -68
- package/dist/validators/bigint.d.ts +7 -0
- package/dist/validators/bigint.js +1 -228
- package/dist/validators/boolean.js +1 -142
- package/dist/validators/codec.js +1 -200
- package/dist/validators/custom.d.ts +20 -10
- package/dist/validators/custom.js +1 -67
- package/dist/validators/date.d.ts +2 -0
- package/dist/validators/date.js +1 -274
- package/dist/validators/discriminated-union.d.ts +4 -2
- package/dist/validators/discriminated-union.js +1 -123
- package/dist/validators/enum.d.ts +8 -2
- package/dist/validators/enum.js +1 -150
- package/dist/validators/file.js +1 -125
- package/dist/validators/function.js +1 -58
- package/dist/validators/hex.js +1 -65
- package/dist/validators/index.d.ts +1 -1
- package/dist/validators/index.js +1 -35
- package/dist/validators/intersection.js +1 -116
- package/dist/validators/json.js +1 -66
- package/dist/validators/lazy.js +1 -50
- package/dist/validators/literal.d.ts +8 -3
- package/dist/validators/literal.js +1 -60
- package/dist/validators/map.d.ts +7 -0
- package/dist/validators/map.js +1 -214
- package/dist/validators/nan.js +1 -38
- package/dist/validators/never.js +1 -32
- package/dist/validators/null.js +1 -40
- package/dist/validators/number.d.ts +25 -1
- package/dist/validators/number.js +1 -423
- package/dist/validators/object.d.ts +18 -2
- package/dist/validators/object.js +1 -864
- package/dist/validators/promise.d.ts +6 -7
- package/dist/validators/promise.js +1 -111
- package/dist/validators/record.d.ts +13 -8
- package/dist/validators/record.js +1 -258
- package/dist/validators/set.d.ts +5 -0
- package/dist/validators/set.js +1 -199
- package/dist/validators/string-bool.js +1 -120
- package/dist/validators/string-formats.d.ts +58 -62
- package/dist/validators/string-formats.js +1 -135
- package/dist/validators/string.d.ts +49 -10
- package/dist/validators/string.js +1 -4
- package/dist/validators/symbol.js +1 -58
- package/dist/validators/template-literal.js +1 -103
- package/dist/validators/tuple.d.ts +17 -13
- package/dist/validators/tuple.js +1 -183
- package/dist/validators/uint8array.js +1 -101
- package/dist/validators/undefined.js +1 -40
- package/dist/validators/union.d.ts +1 -0
- package/dist/validators/union.js +1 -187
- package/dist/validators/unknown.js +1 -37
- package/dist/validators/void.js +1 -44
- package/dist/validators/xor.d.ts +2 -2
- package/dist/validators/xor.js +1 -66
- package/package.json +240 -238
- package/dist/chunks/errors-core-BeiFUtZM.js +0 -81
- package/dist/chunks/index-0R2ntSud.js +0 -508
- package/dist/chunks/index-BvH403Yy.js +0 -88
- package/dist/chunks/security-B0Pd_vSY.js +0 -35
- package/dist/chunks/string-BJRQod3t.js +0 -530
- package/dist/cjs/chunks/errors-core-DWxLFs2f.cjs +0 -83
- package/dist/cjs/chunks/index-BkI37108.cjs +0 -538
- package/dist/cjs/chunks/index-Cc3bjUMX.cjs +0 -91
- package/dist/cjs/chunks/security-Dc3Jh13T.cjs +0 -37
- package/dist/cjs/chunks/string-BKZrc4hs.cjs +0 -533
package/dist/cli/index.js
CHANGED
|
@@ -1,205 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* VLD CLI Tool
|
|
5
|
-
*
|
|
6
|
-
* Command-line interface for VLD validation library.
|
|
7
|
-
* Provides commands for validation, schema generation, and benchmarking.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Parse command line arguments
|
|
11
|
-
*/
|
|
12
|
-
function parseArgs(args, options = []) {
|
|
13
|
-
const result = {
|
|
14
|
-
positional: [],
|
|
15
|
-
options: {}
|
|
16
|
-
};
|
|
17
|
-
// Set defaults
|
|
18
|
-
for (const opt of options) {
|
|
19
|
-
if (opt.default !== undefined) {
|
|
20
|
-
result.options[opt.name] = opt.default;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
let i = 0;
|
|
24
|
-
while (i < args.length) {
|
|
25
|
-
const arg = args[i];
|
|
26
|
-
if (arg === undefined) {
|
|
27
|
-
i++;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (arg.startsWith('--')) {
|
|
31
|
-
// Long option
|
|
32
|
-
const [name, value] = arg.slice(2).split('=');
|
|
33
|
-
if (name === undefined || name === '') {
|
|
34
|
-
i++;
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
const option = options.find((o) => o.name === name);
|
|
38
|
-
if (option) {
|
|
39
|
-
if (option.type === 'boolean') {
|
|
40
|
-
result.options[name] = value !== 'false';
|
|
41
|
-
}
|
|
42
|
-
else if (value !== undefined) {
|
|
43
|
-
result.options[name] = option.type === 'number' ? Number(value) : value;
|
|
44
|
-
}
|
|
45
|
-
else if (i + 1 < args.length && args[i + 1] !== undefined && !args[i + 1].startsWith('-')) {
|
|
46
|
-
i++;
|
|
47
|
-
const nextArg = args[i];
|
|
48
|
-
if (nextArg !== undefined) {
|
|
49
|
-
result.options[name] = option.type === 'number' ? Number(nextArg) : nextArg;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
result.options[name] = true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else if (arg.startsWith('-')) {
|
|
58
|
-
// Short option
|
|
59
|
-
const short = arg.slice(1);
|
|
60
|
-
const option = options.find((o) => o.short === short);
|
|
61
|
-
if (option) {
|
|
62
|
-
if (option.type === 'boolean') {
|
|
63
|
-
result.options[option.name] = true;
|
|
64
|
-
}
|
|
65
|
-
else if (i + 1 < args.length && args[i + 1] !== undefined && !args[i + 1].startsWith('-')) {
|
|
66
|
-
i++;
|
|
67
|
-
const nextArg = args[i];
|
|
68
|
-
if (nextArg === undefined) {
|
|
69
|
-
i++;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
result.options[option.name] =
|
|
73
|
-
option.type === 'number' ? Number(nextArg) : nextArg;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
// Positional argument
|
|
79
|
-
result.positional.push(arg);
|
|
80
|
-
}
|
|
81
|
-
i++;
|
|
82
|
-
}
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Create a CLI instance
|
|
87
|
-
*/
|
|
88
|
-
function createCli(name, version, description) {
|
|
89
|
-
const commands = new Map();
|
|
90
|
-
const cli = {
|
|
91
|
-
name,
|
|
92
|
-
version,
|
|
93
|
-
description,
|
|
94
|
-
commands,
|
|
95
|
-
command(cmd) {
|
|
96
|
-
commands.set(cmd.name, cmd);
|
|
97
|
-
if (cmd.aliases) {
|
|
98
|
-
for (const alias of cmd.aliases) {
|
|
99
|
-
commands.set(alias, cmd);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return this;
|
|
103
|
-
},
|
|
104
|
-
help() {
|
|
105
|
-
const lines = [];
|
|
106
|
-
lines.push(pigment.bold(`${this.name} v${this.version}`));
|
|
107
|
-
lines.push(pigment.dim(description));
|
|
108
|
-
lines.push('');
|
|
109
|
-
lines.push(pigment.bold('Usage:'));
|
|
110
|
-
lines.push(` ${name} <command> [options]`);
|
|
111
|
-
lines.push('');
|
|
112
|
-
lines.push(pigment.bold('Commands:'));
|
|
113
|
-
const uniqueCommands = new Map();
|
|
114
|
-
for (const [, cmd] of commands) {
|
|
115
|
-
if (!uniqueCommands.has(cmd.name)) {
|
|
116
|
-
uniqueCommands.set(cmd.name, cmd);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
for (const [cmdName, cmd] of uniqueCommands) {
|
|
120
|
-
const aliases = cmd.aliases?.length ? pigment.dim(` (${cmd.aliases.join(', ')})`) : '';
|
|
121
|
-
lines.push(` ${pigment.cyan(cmdName)}${aliases}`);
|
|
122
|
-
lines.push(` ${cmd.description}`);
|
|
123
|
-
}
|
|
124
|
-
lines.push('');
|
|
125
|
-
lines.push(pigment.bold('Options:'));
|
|
126
|
-
lines.push(` ${pigment.cyan('-h, --help')} Show help`);
|
|
127
|
-
lines.push(` ${pigment.cyan('-v, --version')} Show version`);
|
|
128
|
-
return lines.join('\n');
|
|
129
|
-
},
|
|
130
|
-
async run(args) {
|
|
131
|
-
// Handle help
|
|
132
|
-
if (args.includes('--help') || args.includes('-h') || args.length === 0) {
|
|
133
|
-
console.log(this.help());
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
// Handle version
|
|
137
|
-
if (args.includes('--version') || args.includes('-v')) {
|
|
138
|
-
console.log(`${this.name} v${this.version}`);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
// Get command
|
|
142
|
-
const cmdName = args[0];
|
|
143
|
-
if (cmdName === undefined) {
|
|
144
|
-
console.log(this.help());
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const cmd = commands.get(cmdName);
|
|
148
|
-
if (!cmd) {
|
|
149
|
-
console.error(pigment.red(`Unknown command: ${cmdName}`));
|
|
150
|
-
console.log('');
|
|
151
|
-
console.log(this.help());
|
|
152
|
-
process.exitCode = 1;
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
// Parse arguments
|
|
156
|
-
const parsed = parseArgs(args.slice(1), cmd.options);
|
|
157
|
-
// Map positional arguments
|
|
158
|
-
const positionalArgs = {};
|
|
159
|
-
if (cmd.arguments) {
|
|
160
|
-
for (let i = 0; i < cmd.arguments.length; i++) {
|
|
161
|
-
const arg = cmd.arguments[i];
|
|
162
|
-
if (arg === undefined) {
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
if (i < parsed.positional.length) {
|
|
166
|
-
positionalArgs[arg.name] = parsed.positional[i];
|
|
167
|
-
}
|
|
168
|
-
else if (arg.default !== undefined) {
|
|
169
|
-
positionalArgs[arg.name] = arg.default;
|
|
170
|
-
}
|
|
171
|
-
else if (arg.required) {
|
|
172
|
-
console.error(pigment.red(`Missing required argument: ${arg.name}`));
|
|
173
|
-
process.exitCode = 1;
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
// Check required options
|
|
179
|
-
if (cmd.options) {
|
|
180
|
-
for (const opt of cmd.options) {
|
|
181
|
-
if (opt.required && parsed.options[opt.name] === undefined) {
|
|
182
|
-
console.error(pigment.red(`Missing required option: --${opt.name}`));
|
|
183
|
-
process.exitCode = 1;
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
// Execute command
|
|
189
|
-
try {
|
|
190
|
-
await cmd.action(positionalArgs, parsed.options);
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
console.error(pigment.red('Error:'), error.message);
|
|
194
|
-
process.exitCode = 1;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
return cli;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* VLD CLI instance
|
|
202
|
-
*/
|
|
203
|
-
const vldCli = createCli('vld', '1.5.0', 'Fast TypeScript Validation Library');
|
|
204
|
-
|
|
205
|
-
export { createCli as cli, createCli, vldCli };
|
|
1
|
+
import o from"../pigment.js";function e(e,s,n){const i=new Map,t={name:e,version:s,description:n,commands:i,command(o){if(i.set(o.name,o),o.aliases)for(const e of o.aliases)i.set(e,o);return this},help(){const s=[];s.push(o.bold(`${this.name} v${this.version}`)),s.push(o.dim(n)),s.push(""),s.push(o.bold("Usage:")),s.push(` ${e} <command> [options]`),s.push(""),s.push(o.bold("Commands:"));const t=new Map;for(const[,o]of i)t.has(o.name)||t.set(o.name,o);for(const[e,n]of t){const i=n.aliases?.length?o.dim(` (${n.aliases.join(", ")})`):"";s.push(` ${o.cyan(e)}${i}`),s.push(` ${n.description}`)}return s.push(""),s.push(o.bold("Options:")),s.push(` ${o.cyan("-h, --help")} Show help`),s.push(` ${o.cyan("-v, --version")} Show version`),s.join("\n")},async run(e){if(e.includes("--help")||e.includes("-h")||0===e.length)return void console.log(this.help());if(e.includes("--version")||e.includes("-v"))return void console.log(`${this.name} v${this.version}`);const s=e[0];if(void 0===s)return void console.log(this.help());const n=i.get(s);if(!n)return console.error(o.red(`Unknown command: ${s}`)),console.log(""),console.log(this.help()),void(process.exitCode=1);const t=function(o,e=[]){const s={positional:[],options:{}};for(const o of e)void 0!==o.default&&(s.options[o.name]=o.default);let n=0;for(;n<o.length;){const i=o[n];if(void 0!==i){if(i.startsWith("--")){const[t,r]=i.slice(2).split("=");if(void 0===t||""===t){n++;continue}const l=e.find(o=>o.name===t);if(l)if("boolean"===l.type)s.options[t]="false"!==r;else if(void 0!==r)s.options[t]="number"===l.type?Number(r):r;else if(n+1<o.length&&void 0!==o[n+1]&&!o[n+1].startsWith("-")){n++;const e=o[n];void 0!==e&&(s.options[t]="number"===l.type?Number(e):e)}else s.options[t]=!0}else if(i.startsWith("-")){const t=i.slice(1),r=e.find(o=>o.short===t);if(r)if("boolean"===r.type)s.options[r.name]=!0;else if(n+1<o.length&&void 0!==o[n+1]&&!o[n+1].startsWith("-")){n++;const e=o[n];if(void 0===e){n++;continue}s.options[r.name]="number"===r.type?Number(e):e}}else s.positional.push(i);n++}else n++}return s}(e.slice(1),n.options),r={};if(n.arguments)for(let e=0;e<n.arguments.length;e++){const s=n.arguments[e];if(void 0!==s)if(e<t.positional.length)r[s.name]=t.positional[e];else if(void 0!==s.default)r[s.name]=s.default;else if(s.required)return console.error(o.red(`Missing required argument: ${s.name}`)),void(process.exitCode=1)}if(n.options)for(const e of n.options)if(e.required&&void 0===t.options[e.name])return console.error(o.red(`Missing required option: --${e.name}`)),void(process.exitCode=1);try{await n.action(r,t.options)}catch(e){console.error(o.red("Error:"),e.message),process.exitCode=1}}};return t}const s=e("vld","1.5.0","Fast TypeScript Validation Library");export{e as cli,e as createCli,s as vldCli};
|
package/dist/codecs/index.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import '../validators/base64.js';
|
|
3
|
-
import '../validators/hex.js';
|
|
4
|
-
import '../validators/uint8array.js';
|
|
5
|
-
import '../chunks/string-BJRQod3t.js';
|
|
6
|
-
import '../validators/number.js';
|
|
7
|
-
import '../validators/bigint.js';
|
|
8
|
-
import '../validators/boolean.js';
|
|
9
|
-
import '../validators/date.js';
|
|
10
|
-
import '../validators/unknown.js';
|
|
11
|
-
export { b as base64Json, a as base64ToBytes, d as base64UrlToBytes, e as base64urlToBytes, f as bytesToUtf8, g as epochMillisToDate, h as epochSecondsToDate, i as hexLowerToBytes, j as hexToBytes, l as invertCodec, m as isoDatetimeToDate, n as jsonCodec, o as jwtPayload, p as numberToBigInt, s as stringToBigInt, q as stringToBoolean, r as stringToHttpURL, t as stringToInt, u as stringToNumber, v as stringToURL, B as uriComponent, C as utf8ToBytes } from '../chunks/index-0R2ntSud.js';
|
|
1
|
+
import"../validators/codec.js";import"../validators/base64.js";import"../validators/hex.js";import"../validators/uint8array.js";import"../validators/string.js";import"../validators/number.js";import"../validators/bigint.js";import"../validators/boolean.js";import"../validators/date.js";import"../validators/unknown.js";export{b as base64Json,a as base64ToBytes,d as base64UrlToBytes,e as base64urlToBytes,f as bytesToUtf8,g as epochMillisToDate,h as epochSecondsToDate,i as hexLowerToBytes,j as hexToBytes,l as invertCodec,m as isoDatetimeToDate,n as jsonCodec,o as jwtPayload,p as numberToBigInt,s as stringToBigInt,q as stringToBoolean,r as stringToHttpURL,t as stringToInt,u as stringToNumber,v as stringToURL,B as uriComponent,C as utf8ToBytes}from"../chunks/index-CkbfQQ4n.js";
|