MCPcopy
hub / github.com/di-sukharev/opencommit / create

Method create

out/cli.cjs:31695–31716  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 4

getDiscriminatorFunction · 0.85
processCreateParamsFunction · 0.85
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected