Type Magic: validation on type property
How to validate defs in object type properties?
I did that three days ago but I forgot how
20 Replies
Apparently I need to use
keyof def
somewhere
What is the point of this just so you don't have to write
"200"
instead of 200
?I want to validate an arbitrary definition schema with Type definitions on random predefined places
Does not have to be specifically ArkType definitions
Hah, there may be some booleans and object configs which are unrelated to definitions@ssalbdivad
Sounds like it would be unnecessary once I support metadata
e.g. if I'd want to have an Elysia config that has format
where half of properties are definitions and half are not
I would probably just list the keys you want to be treated as type defs in a tuple since you'll need that logic to know what to parse at runtime anyways
And you can infer the type from it and use that to select which are validated as definitions
You mean like
[body, headers, query, ...]
?Yeah in strings
Nah they all are optional
That doesn't matter
what's that
ah
Hmm
Anyways
I got it to work so it's fine now
body: Type
and equals<Required<schema>[K], Type
is a crazy way to do this
Your call I supposeThat looks cool in optional autocompletion
🤔
Tho maybe I could equals to "type" and morph it to Type
How can something look cool in autocompletion haha
That's kind of a lie though
Well, kind of
You can place a Type there anyways
You can but you don't have to and usually you wouldn't want to
Make your own type for it since it's just for display purposes anyways call it
ArkTypeDefinition
or somethingOkay makes sense
It's a clever idea though it hadn't occurred to me to manipulate that display. I wonder if it could be used to simplify how
validateDefinition
displays as you type