scopes from arktype aren't supported in arktype validator
Which middleware has the bug?
@hono/arktype-validator
What version of the middleware?
2.0.1
What version of Hono are you using?
4.7.11
What runtime/platform is your app running on? (with version if possible)
NodeJS 22
What steps can reproduce the bug?
using unextended type works properly
arktypeValidator('json', type({}));
extending arktype using built-in scopes does not:
const scope = type.scope({
customType: type({})
})
arktypeValidator('json', scope.type({}));
it results in the following error:
Argument of type 'Type<object, { customType: object; }>' is not assignable to parameter of type 'Type<unknown, {}>'.
The types of 'as(...).$.exportedNames' are incompatible between these types.
Type 'array<"customType">' is not assignable to type 'array
What is the expected behavior?
it shouldn't affect the behaviour, scopes are only for grouping models for ease of use
What do you see instead?
for middleware to accept types from scopes
Additional information
No response
also looking at the code in middleware/packages/arktype-validator/src/index.ts line 36:
// @ts-expect-error not typed well
this probably is the culprit
@lunarW1TCH Thank you for the issue.
Hi @MonsterDeveloper. Can you handle this issue?
@yusukebe I looked into it and seems like it would be possible to fix the @hono/arktype-validator
However, the official ArkType docs recommend using Standard Schema for library authors.
Made me wonder, what's the point of supporting the @hono/arktype-validator, @hono/valibot-validator, @hono/zod-validator, etc, when in theory @hono/standard-validator can replace all of them?
The sValidator works perfectly fine with Arktype Scopes (so the issue is not relevant there).
Standard Schema supports a bunch of validators:
Maybe it's time to deprecate individual validators and instead focus on the standard schema?
What do you think?
I just switched to sValidator and everything works perfectly :3
@MonsterDeveloper Thank you for the comment.
Maybe it's time to deprecate individual validators and instead focus on the standard schema? What do you think?
I also think it's time. I created the proposal based on your comment: #1241