A
arktype•3w ago
Tehrin

Standard Schema validation output issues can't be flattened

As far as I can tell the other validation libraries will have multiple issues for the same path, but for arktype they all get grouped in an intersection error type (if I have something like string < 10 & /some_regex/ and it fails both I feel like the default should flatten all errors in arktype to match the others behavior, or at least make it configurable? Or is the intention to just wrap our own StandardSchema around arktype where we flatten if needed?
5 Replies
ssalbdivad
ssalbdivad•3w ago
Errors are flattened by path because that's usually the most actionable result, but ArkErrors also has a .flat prop you can use to get this Also you can get individual errors from an intersection error so it's not lossy
declare const e: ArkErrors

const one = e[0]

if (one.hasCode("intersection")) one.errors
declare const e: ArkErrors

const one = e[0]

if (one.hasCode("intersection")) one.errors
Tehrin
TehrinOP•3w ago
Myeah, but you lack those when passing an arktype schema into a place expecting a StandardSchema
ssalbdivad
ssalbdivad•3w ago
Maybe other schema libraries should change to group errors by path so they're more useful and save user some work then 😉
Tehrin
TehrinOP•3w ago
Well, I guess wrapping arktype into a (flaterrors standard schema) is not that hard
ssalbdivad
ssalbdivad•3w ago
There's nothing about this grouping that doesn't conform to Standard Schema. If you need the granular details this way, you'll have to check if it's an arktype Type then acces .flat

Did you find this page helpful?