* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. * However, it only allows a union of objects, all of which need to share a discriminator property. This property must * have a different value for each object
(discriminator, options, params)
| 31693 | * @param params |
| 31694 | */ |
| 31695 | static create(discriminator, options, params) { |
| 31696 | const optionsMap = /* @__PURE__ */ new Map(); |
| 31697 | for (const type2 of options) { |
| 31698 | const discriminatorValues = getDiscriminator(type2.shape[discriminator]); |
| 31699 | if (!discriminatorValues.length) { |
| 31700 | throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); |
| 31701 | } |
| 31702 | for (const value of discriminatorValues) { |
| 31703 | if (optionsMap.has(value)) { |
| 31704 | throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); |
| 31705 | } |
| 31706 | optionsMap.set(value, type2); |
| 31707 | } |
| 31708 | } |
| 31709 | return new _ZodDiscriminatedUnion({ |
| 31710 | typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion, |
| 31711 | discriminator, |
| 31712 | options, |
| 31713 | optionsMap, |
| 31714 | ...processCreateParams(params) |
| 31715 | }); |
| 31716 | } |
| 31717 | }; |
| 31718 | exports2.ZodDiscriminatedUnion = ZodDiscriminatedUnion; |
| 31719 | function mergeValues(a4, b7) { |
nothing calls this directly
no test coverage detected