The key name used to discriminate between variants.
OptionalnullableWhen true, the field becomes optional (T | undefined).
Must be "discriminatedUnion" to indicate a discriminated union field.
A record mapping each discriminator value to a NonUnionObjectSchema describing that variant's fields (excluding the discriminator itself). Discriminated unions cannot be nested inside other discriminated unions.
A schema field definition for a discriminated union type.
The
discriminatornames the key used to distinguish variants, andvariantsmaps each discriminator value to an ObjectSchema describing that variant's fields. The discriminator key is automatically added to each variant's inferred type as a string literal.Update semantics: Discriminated union fields always use full replacement on update (
SET #field = :value), never document path merging. This is because:Unlike ObjectFieldDef, discriminated union fields can be nullable because they always use full replacement on update rather than document path expressions, so there is no risk of DynamoDB failing on a missing parent path.
Scoping constraints:
Example