arktypea
arktype11mo ago
dibbo

Intersection/Union Validation Errors

I'm a bit confused around how errors are calculated when validating objects using types involving intersections/unions.

For example, given the following
const base = type({name:'string'})
const union = type({a:"1", 'b?':"2"}).or({a:"'a'", 'b?':"'b'", 'c?':"'c'"})
const validator = base.and(union);
const res = validator({});

I would expect res to contain errors on both
name
and a since they are the common required fields, but instead I only get an error reported on a. Is this because ArkType (or TS?) needs to have a fully resolved(?) type before it can validate all fields?
Was this page helpful?