Genshii
Aarktype
•Created by Genshii on 2/26/2025 in #questions
Configure errors in a scope
Is it possible to set a
expected
/actual
/etc handler for every type in a scope?
I have something like this:
The error summary looks as follows: value at [0].myKey must be a number (was a string)
Ultimately what I want to do is tell the user the name of object that had the error (let's just assume the name
property is always on the object).
So something like: (for object with name 'foo'): value at [0].myKey must be a number (was a string)
I was thinking of doing something like this:
But I would need to apply that to all types contained within my foo
.44 replies
Aarktype
•Created by Genshii on 2/25/2025 in #questions
Get ts type that accepts type arguments
I have a type that looks like this:
I would prefer to instead define a Type and infer the ts type.
So ultimately I'd want to do this:
But of course
PluginInstance
doesn't take any type arguments. Is it possible to define generics on my schema and have the inferred type accept those type arguments?
I tried playing around with scopes, tried doing const pluginInstanceSchema = type("<Input, TInput, Diff>", { ...
, but didn't really get anywhere.25 replies
Aarktype
•Created by Genshii on 2/25/2025 in #questions
"Custom" type or equivalent to valibot.custom()?
I might just be missing something obvious, but I want to do something like this:
Obviously
SomeType
isn't a valid value, so I could do something like this:
But I have a feeling that's not the right way to do it. Is there something like valibot's custom?11 replies