tods-competition-factory 1.6.26 → 1.6.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1629,6 +1629,13 @@ var MatchUpStatusEnum = /* @__PURE__ */ ((MatchUpStatusEnum2) => {
1629
1629
  MatchUpStatusEnum2["Walkover"] = "WALKOVER";
1630
1630
  return MatchUpStatusEnum2;
1631
1631
  })(MatchUpStatusEnum || {});
1632
+ var GenderEnum = /* @__PURE__ */ ((GenderEnum2) => {
1633
+ GenderEnum2["Any"] = "ANY";
1634
+ GenderEnum2["Female"] = "FEMALE";
1635
+ GenderEnum2["Male"] = "MALE";
1636
+ GenderEnum2["Mixed"] = "MIXED";
1637
+ return GenderEnum2;
1638
+ })(GenderEnum || {});
1632
1639
  var ParticipantTypeEnum = /* @__PURE__ */ ((ParticipantTypeEnum2) => {
1633
1640
  ParticipantTypeEnum2["Group"] = "GROUP";
1634
1641
  ParticipantTypeEnum2["Individual"] = "INDIVIDUAL";
@@ -1638,6 +1645,7 @@ var ParticipantTypeEnum = /* @__PURE__ */ ((ParticipantTypeEnum2) => {
1638
1645
  })(ParticipantTypeEnum || {});
1639
1646
 
1640
1647
  function validateTieFormat(params) {
1648
+ const checkGender = !!(params?.enforceGender !== false && params?.gender);
1641
1649
  const checkCollectionIds = params?.checkCollectionIds;
1642
1650
  const tieFormat = params?.tieFormat;
1643
1651
  const stack = "validateTieFormat";
@@ -1646,9 +1654,9 @@ function validateTieFormat(params) {
1646
1654
  errors.push("tieFormat must be an object");
1647
1655
  return decorateResult({
1648
1656
  result: {
1657
+ context: { tieFormat, errors },
1649
1658
  error: INVALID_TIE_FORMAT,
1650
- stack,
1651
- context: { tieFormat, errors }
1659
+ stack
1652
1660
  }
1653
1661
  });
1654
1662
  }
@@ -1656,9 +1664,9 @@ function validateTieFormat(params) {
1656
1664
  errors.push("tieFormat.winCriteria must be an object");
1657
1665
  return decorateResult({
1658
1666
  result: {
1667
+ context: { tieFormat, errors },
1659
1668
  error: INVALID_TIE_FORMAT,
1660
- stack,
1661
- context: { tieFormat, errors }
1669
+ stack
1662
1670
  }
1663
1671
  });
1664
1672
  }
@@ -1666,9 +1674,9 @@ function validateTieFormat(params) {
1666
1674
  errors.push(mustBeAnArray("tieFormat.collectionDefinitions"));
1667
1675
  return decorateResult({
1668
1676
  result: {
1677
+ context: { tieFormat, errors },
1669
1678
  error: INVALID_TIE_FORMAT,
1670
- stack,
1671
- context: { tieFormat, errors }
1679
+ stack
1672
1680
  }
1673
1681
  });
1674
1682
  }
@@ -1679,8 +1687,10 @@ function validateTieFormat(params) {
1679
1687
  if ((setValue || scoreValue) && !collectionValue)
1680
1688
  aggregateValueImperative = true;
1681
1689
  const { valid: valid2, errors: collectionDefinitionErrors } = validateCollectionDefinition({
1690
+ referenceGender: params.gender,
1682
1691
  collectionDefinition,
1683
- checkCollectionIds
1692
+ checkCollectionIds,
1693
+ checkGender
1684
1694
  });
1685
1695
  if (valid2) {
1686
1696
  return true;
@@ -1726,7 +1736,9 @@ function validateTieFormat(params) {
1726
1736
  }
1727
1737
  function validateCollectionDefinition({
1728
1738
  collectionDefinition,
1729
- checkCollectionIds
1739
+ checkCollectionIds,
1740
+ referenceGender,
1741
+ checkGender
1730
1742
  }) {
1731
1743
  const errors = [];
1732
1744
  if (typeof collectionDefinition !== "object") {
@@ -1745,19 +1757,17 @@ function validateCollectionDefinition({
1745
1757
  matchUpValue,
1746
1758
  matchUpType,
1747
1759
  scoreValue,
1748
- setValue
1760
+ setValue,
1761
+ gender
1749
1762
  } = collectionDefinition;
1750
1763
  if (checkCollectionIds && typeof collectionId !== "string") {
1751
1764
  errors.push(`collectionId is not type string: ${collectionId}`);
1752
- return { errors };
1753
1765
  }
1754
1766
  if (typeof matchUpCount !== "number") {
1755
1767
  errors.push(`matchUpCount is not type number: ${matchUpCount}`);
1756
- return { errors };
1757
1768
  }
1758
1769
  if (matchUpType && ![TypeEnum.Singles, TypeEnum.Doubles].includes(matchUpType)) {
1759
1770
  errors.push(`matchUpType must be SINGLES or DOUBLES: ${matchUpType}`);
1760
- return { errors };
1761
1771
  }
1762
1772
  const valueDeclarations = [!!collectionValueProfiles?.length].concat(
1763
1773
  [matchUpValue, collectionValue, scoreValue, setValue].map(
@@ -1768,15 +1778,12 @@ function validateCollectionDefinition({
1768
1778
  errors.push(
1769
1779
  "Missing value definition for matchUps: matchUpValue, collectionValue, or collectionValueProfiles"
1770
1780
  );
1771
- return { errors };
1772
1781
  }
1773
1782
  if (matchUpValue && typeof matchUpValue !== "number") {
1774
1783
  errors.push(`matchUpValue is not type number: ${matchUpValue}`);
1775
- return { errors };
1776
1784
  }
1777
1785
  if (collectionValue && typeof collectionValue !== "number") {
1778
1786
  errors.push(`collectionValue is not type number: ${collectionValue}`);
1779
- return { errors };
1780
1787
  }
1781
1788
  if (collectionValueProfiles) {
1782
1789
  const result = validateCollectionValueProfile({
@@ -1785,17 +1792,19 @@ function validateCollectionDefinition({
1785
1792
  });
1786
1793
  if (result.errors) {
1787
1794
  errors.push(...result.errors);
1788
- return { errors };
1789
1795
  }
1790
1796
  }
1791
1797
  if (collectionGroupNumber && typeof collectionGroupNumber !== "number") {
1792
- errors.push(`collectionValue is not type number: ${collectionValue}`);
1793
- return { errors };
1798
+ errors.push(`collectionGroupNumber is not type number: ${collectionValue}`);
1794
1799
  }
1795
1800
  if (matchUpFormat && !matchUpFormatCode.isValid(matchUpFormat)) {
1796
1801
  errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
1797
- return { errors };
1798
1802
  }
1803
+ if (checkGender && referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender) {
1804
+ errors.push(`Invalid gender: ${gender}`);
1805
+ }
1806
+ if (errors.length)
1807
+ return { errors };
1799
1808
  return { valid: true };
1800
1809
  }
1801
1810
  function validateCollectionValueProfile({