Problem with validation in 2.0 dev?
I'm using
2.0.0-dev.11
and cannot figure out why some very basic validation fails. Short example:
The output I get from running this is:
I'd expected errors for score
, nospace
, tags
and maybe tags[1]
as well. Anything very simple I'm missing?11 Replies
If I remove some fields from the schema:
The score error appears:
And when the schema looks like this, the tags error appear:
Seems like there is an error count in traversal.ts that gets triggered and doesn't include some errors: https://github.com/arktypeio/arktype/blob/08b151eb07f9704080cc68db7e3ab551fafca368/ark/schema/shared/traversal.ts#L107
GitHub
arktype/ark/schema/shared/traversal.ts at 08b151eb07f9704080cc68db7...
TypeScript's 1:1 validator, optimized from editor to runtime - arktypeio/arktype
This is what the score validator looks like:
For
date
, passing in a value of undefined
is indeed incorrect from my understanding. Either it should be a valid date or not provided. Not providing and providing as undefined are two different things
You'd need date: "Date|undefined"
or "date?": "Date|undefined"
if the key can be missing (again, set to undefined isn't the same as missing)Probably yes, but all errors should be reported anyway
@ssalbdivad sorry to bother you, it's just that I'd really like 2.0 to work with Superforms. 😌 But it seems like there is a
ctx.failFast
check missing in the above code? Since for form validation, it's essential to have all errors reported.Ah, I see, you're pointing out not all errors are raised
Yeah, that seems like a bug
Yes, but what you say is interesting as well. I don't know if there is an
in
validator in ArkType, otherwise it could be the same (as a missing key is undefined), but I don't know.Thanks for the detailed info here, I recently made some changes to how structure nodes are compiled to accomodate index types and this is definitely a bug resulting from that. Will release a new version imminently to resolve
Nice, thank you very much 🙂
Try
2.0.0-dev.12
when you get a chance 🙂Whohoo, worked directly!