-
-
Notifications
You must be signed in to change notification settings - Fork 37
Conversation
Codecov Report
@@ Coverage Diff @@
## main #56 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 21 21
Lines 264 263 -1
Branches 33 33
=========================================
- Hits 264 263 -1
Continue to review full report at Codecov.
|
The whole point of the module is to provide TS-and-JS side validation of the data, so you know ahead of time if your commands are valid. I'd love to know how the errors reported by Joi look like. Does Joi report all validation errors encountered or just the first one? |
When using objects, Joi can report multiple errors (not enabled in this pr yet), but not when using multiple asserts. For example: const schema = Joi.object().keys({
a: Joi.string(),
b: Joi.number()
});
Joi.assert({a: 1, b: false}, schema, { abortEarly: false }) and the error is
|
Other validation libraries, such as const schema = z.object({
a: z.string(),
b: z.number()
});
schema.parse({ a: 1, b: false }); which throws ZodError: [
{
"code": "invalid_type",
"expected": "string",
"received": "number",
"path": [
"a"
],
"message": "Expected string, received number"
},
{
"code": "invalid_type",
"expected": "number",
"received": "boolean",
"path": [
"b"
],
"message": "Expected number, received boolean"
}
]
at new ZodError (E:\builders\builders-validation\node_modules\.pnpm\z[email protected]\node_modules\zod\src\ZodError.ts:140:5)
at handleResult (E:\builders\builders-validation\node_modules\.pnpm\z[email protected]\node_modules\zod\src\types.ts:72:19)
at ZodObject.ZodType.safeParse (E:\builders\builders-validation\node_modules\.pnpm\z[email protected]\node_modules\zod\src\types.ts:184:12)
at ZodObject.ZodType.parse (E:\builders\builders-validation\node_modules\.pnpm\z[email protected]\node_modules\zod\src\types.ts:162:25)
at Object.<anonymous> (E:\builders\builders-validation\index.ts:16:8)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (E:\builders\builders-validation\node_modules\.pnpm\t[email protected]_0cb88d80cb04d25b21fa3ec194608c65\node_modules\ts-node\src\index.ts:1371:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (E:\builders\builders-validation\node_modules\.pnpm\t[email protected]_0cb88d80cb04d25b21fa3ec194608c65\node_modules\ts-node\src\index.ts:1374:12)
at Module.load (node:internal/modules/cjs/loader:981:32) {
issues: [
{
code: 'invalid_type',
expected: 'string',
received: 'number',
path: [Array],
message: 'Expected string, received number'
},
{
code: 'invalid_type',
expected: 'number',
received: 'boolean',
path: [Array],
message: 'Expected number, received boolean'
}
],
format: [Function (anonymous)],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)],
flatten: [Function (anonymous)]
} |
Honestly I just chose the most popular validation library I could find and really couldn't care less which one replaces |
I would love to see this merged! |
We decided to go with |
awesome! |
Please describe the changes this PR makes and why it should be merged:
Finally fixes #54 (ow hasn't supported ESM in at least 6 months, it likely never did).
To fix ESM, the package author is planning on moving to ESM only, which in turn will break cjs users (they can still use dynamic imports but it's a pretty terrible solution, plus I don't know if the minifier would recognize this and minify accordingly?). So the option was to alienate esm users, or alienate cjs. The best solution I could think of was to just ditch ow.
Another solution would be to remove validation entirely because Discord's documentation is good enough as a reference for users to use instead. Or someone could roll back changes between v0.7.0 and 0.8.x that causes ow to get used in
SlashCommandBuilder
?Another user experiencing the same issue.
Status and versioning classification: