UnionValidatorConfig
Configuration type for union validators. Each variant must be a validator that produces an object with the discriminator key set to the variant name.
type UnionValidatorConfig<Key extends string, Config> = {
readonly [Variant in keyof Config]: Validatable<any> & {
validate(input: any): {
readonly [K in Key]: Variant;
};
};
};Example
type ShapeConfig = UnionValidatorConfig<
"type",
{
circle: Validatable<{ type: "circle"; radius: number }>;
square: Validatable<{ type: "square"; size: number }>;
}
>;Prev
TLVideoShape