@plasius/schema 1.2.6 → 1.2.8

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.
package/dist/index.d.cts CHANGED
@@ -8,6 +8,21 @@ interface PII {
8
8
  purpose?: string;
9
9
  }
10
10
 
11
+ interface ValidationIssueInput {
12
+ code: string;
13
+ message: string;
14
+ path?: string;
15
+ }
16
+ interface ValidationIssue {
17
+ path: string;
18
+ code: string;
19
+ message: string;
20
+ }
21
+ type FieldValidatorResult = boolean | string | ValidationIssueInput | ValidationIssueInput[];
22
+ type FieldValidator<T = unknown> = {
23
+ bivarianceHack(value: T): FieldValidatorResult;
24
+ }["bivarianceHack"];
25
+
11
26
  type FieldType$1 = "string" | "number" | "boolean" | "object" | "array" | "ref";
12
27
 
13
28
  type FieldExposure = "public" | "internal";
@@ -18,7 +33,7 @@ declare class FieldBuilder<TExternal = unknown, TInternal = TExternal> {
18
33
  isSystem: boolean;
19
34
  isImmutable: boolean;
20
35
  isRequired: boolean;
21
- _validator?: (value: any) => boolean;
36
+ _validator?: FieldValidator<TInternal>;
22
37
  _description: string;
23
38
  _version: string;
24
39
  _default?: TInternal | (() => TInternal);
@@ -50,7 +65,7 @@ declare class FieldBuilder<TExternal = unknown, TInternal = TExternal> {
50
65
  public(): FieldBuilder<TExternal, TInternal>;
51
66
  required(): FieldBuilder<TExternal, TInternal>;
52
67
  optional(): FieldBuilder<TExternal, TInternal>;
53
- validator(fn: (value: TInternal) => boolean): FieldBuilder<TExternal, TInternal>;
68
+ validator(fn: FieldValidator<TInternal>): FieldBuilder<TExternal, TInternal>;
54
69
  description(desc: string): FieldBuilder<TExternal, TInternal>;
55
70
  default(value: TInternal | (() => TInternal)): FieldBuilder<TExternal, TInternal>;
56
71
  /**
@@ -162,7 +177,7 @@ interface FieldDefinition<T = unknown> {
162
177
  _shape?: SchemaShape;
163
178
  pii?: PII;
164
179
  exposure?: FieldExposure;
165
- validator?: (value: any) => boolean;
180
+ validator?: FieldValidator<T>;
166
181
  }
167
182
  interface ValidateCompositionOptions {
168
183
  resolveEntity: (type: string, id: string) => Promise<any | null>;
@@ -230,6 +245,7 @@ interface ValidationResult<T> {
230
245
  valid: boolean;
231
246
  value?: DeepReadonly<T>;
232
247
  errors?: string[];
248
+ issues?: ValidationIssue[];
233
249
  }
234
250
  type RefEntityId<T extends string = string> = {
235
251
  type: T;
@@ -636,4 +652,4 @@ declare function isPrivateUseSubtag(value: string): boolean;
636
652
  */
637
653
  declare function validateLanguage(value: unknown): boolean;
638
654
 
639
- export { type DeepReadonly, FieldBuilder, type FieldDefinition, type FieldExposure, type FieldType, type FieldTypeMap, type Infer, IsoLanguageCode, type PIIEnforcement, type RefEntityId, type Schema, type SchemaOptions, type SchemaShape, type SchemaUpgradeFunction, type SchemaUpgradeResult, type SchemaUpgradeSpec, type SchemaUpgradeStep, type SerializeOptions, type ValidateCompositionOptions, type ValidationResult, createComponentSchema, createSchema, field, getAllComponentSchemas, getAllSchemas, getComponentSchema, getSchemaForType, isExtensionSingleton, isExtensionSubtag, isIsoLanguageCode, isPrivateUseSingleton, isPrivateUseSubtag, isRegionSubtag, isScriptSubtag, isVariantSubtag, isoCountryCodes, isoCurrencyCodes, registerComponentSchema, renderSchemaDescription, validateCountryCode, validateCurrencyCode, validateDateTimeISO, validateEmail, validateLanguage, validateName, validatePercentage, validatePhone, validateRichText, validateSafeText, validateSemVer, validateUUID, validateUrl, validateUserId, validateUserIdArray };
655
+ export { type DeepReadonly, FieldBuilder, type FieldDefinition, type FieldExposure, type FieldType, type FieldTypeMap, type FieldValidator, type FieldValidatorResult, type Infer, IsoLanguageCode, type PIIEnforcement, type RefEntityId, type Schema, type SchemaOptions, type SchemaShape, type SchemaUpgradeFunction, type SchemaUpgradeResult, type SchemaUpgradeSpec, type SchemaUpgradeStep, type SerializeOptions, type ValidateCompositionOptions, type ValidationIssue, type ValidationIssueInput, type ValidationResult, createComponentSchema, createSchema, field, getAllComponentSchemas, getAllSchemas, getComponentSchema, getSchemaForType, isExtensionSingleton, isExtensionSubtag, isIsoLanguageCode, isPrivateUseSingleton, isPrivateUseSubtag, isRegionSubtag, isScriptSubtag, isVariantSubtag, isoCountryCodes, isoCurrencyCodes, registerComponentSchema, renderSchemaDescription, validateCountryCode, validateCurrencyCode, validateDateTimeISO, validateEmail, validateLanguage, validateName, validatePercentage, validatePhone, validateRichText, validateSafeText, validateSemVer, validateUUID, validateUrl, validateUserId, validateUserIdArray };
package/dist/index.d.ts CHANGED
@@ -8,6 +8,21 @@ interface PII {
8
8
  purpose?: string;
9
9
  }
10
10
 
11
+ interface ValidationIssueInput {
12
+ code: string;
13
+ message: string;
14
+ path?: string;
15
+ }
16
+ interface ValidationIssue {
17
+ path: string;
18
+ code: string;
19
+ message: string;
20
+ }
21
+ type FieldValidatorResult = boolean | string | ValidationIssueInput | ValidationIssueInput[];
22
+ type FieldValidator<T = unknown> = {
23
+ bivarianceHack(value: T): FieldValidatorResult;
24
+ }["bivarianceHack"];
25
+
11
26
  type FieldType$1 = "string" | "number" | "boolean" | "object" | "array" | "ref";
12
27
 
13
28
  type FieldExposure = "public" | "internal";
@@ -18,7 +33,7 @@ declare class FieldBuilder<TExternal = unknown, TInternal = TExternal> {
18
33
  isSystem: boolean;
19
34
  isImmutable: boolean;
20
35
  isRequired: boolean;
21
- _validator?: (value: any) => boolean;
36
+ _validator?: FieldValidator<TInternal>;
22
37
  _description: string;
23
38
  _version: string;
24
39
  _default?: TInternal | (() => TInternal);
@@ -50,7 +65,7 @@ declare class FieldBuilder<TExternal = unknown, TInternal = TExternal> {
50
65
  public(): FieldBuilder<TExternal, TInternal>;
51
66
  required(): FieldBuilder<TExternal, TInternal>;
52
67
  optional(): FieldBuilder<TExternal, TInternal>;
53
- validator(fn: (value: TInternal) => boolean): FieldBuilder<TExternal, TInternal>;
68
+ validator(fn: FieldValidator<TInternal>): FieldBuilder<TExternal, TInternal>;
54
69
  description(desc: string): FieldBuilder<TExternal, TInternal>;
55
70
  default(value: TInternal | (() => TInternal)): FieldBuilder<TExternal, TInternal>;
56
71
  /**
@@ -162,7 +177,7 @@ interface FieldDefinition<T = unknown> {
162
177
  _shape?: SchemaShape;
163
178
  pii?: PII;
164
179
  exposure?: FieldExposure;
165
- validator?: (value: any) => boolean;
180
+ validator?: FieldValidator<T>;
166
181
  }
167
182
  interface ValidateCompositionOptions {
168
183
  resolveEntity: (type: string, id: string) => Promise<any | null>;
@@ -230,6 +245,7 @@ interface ValidationResult<T> {
230
245
  valid: boolean;
231
246
  value?: DeepReadonly<T>;
232
247
  errors?: string[];
248
+ issues?: ValidationIssue[];
233
249
  }
234
250
  type RefEntityId<T extends string = string> = {
235
251
  type: T;
@@ -636,4 +652,4 @@ declare function isPrivateUseSubtag(value: string): boolean;
636
652
  */
637
653
  declare function validateLanguage(value: unknown): boolean;
638
654
 
639
- export { type DeepReadonly, FieldBuilder, type FieldDefinition, type FieldExposure, type FieldType, type FieldTypeMap, type Infer, IsoLanguageCode, type PIIEnforcement, type RefEntityId, type Schema, type SchemaOptions, type SchemaShape, type SchemaUpgradeFunction, type SchemaUpgradeResult, type SchemaUpgradeSpec, type SchemaUpgradeStep, type SerializeOptions, type ValidateCompositionOptions, type ValidationResult, createComponentSchema, createSchema, field, getAllComponentSchemas, getAllSchemas, getComponentSchema, getSchemaForType, isExtensionSingleton, isExtensionSubtag, isIsoLanguageCode, isPrivateUseSingleton, isPrivateUseSubtag, isRegionSubtag, isScriptSubtag, isVariantSubtag, isoCountryCodes, isoCurrencyCodes, registerComponentSchema, renderSchemaDescription, validateCountryCode, validateCurrencyCode, validateDateTimeISO, validateEmail, validateLanguage, validateName, validatePercentage, validatePhone, validateRichText, validateSafeText, validateSemVer, validateUUID, validateUrl, validateUserId, validateUserIdArray };
655
+ export { type DeepReadonly, FieldBuilder, type FieldDefinition, type FieldExposure, type FieldType, type FieldTypeMap, type FieldValidator, type FieldValidatorResult, type Infer, IsoLanguageCode, type PIIEnforcement, type RefEntityId, type Schema, type SchemaOptions, type SchemaShape, type SchemaUpgradeFunction, type SchemaUpgradeResult, type SchemaUpgradeSpec, type SchemaUpgradeStep, type SerializeOptions, type ValidateCompositionOptions, type ValidationIssue, type ValidationIssueInput, type ValidationResult, createComponentSchema, createSchema, field, getAllComponentSchemas, getAllSchemas, getComponentSchema, getSchemaForType, isExtensionSingleton, isExtensionSubtag, isIsoLanguageCode, isPrivateUseSingleton, isPrivateUseSubtag, isRegionSubtag, isScriptSubtag, isVariantSubtag, isoCountryCodes, isoCurrencyCodes, registerComponentSchema, renderSchemaDescription, validateCountryCode, validateCurrencyCode, validateDateTimeISO, validateEmail, validateLanguage, validateName, validatePercentage, validatePhone, validateRichText, validateSafeText, validateSemVer, validateUUID, validateUrl, validateUserId, validateUserIdArray };
package/dist/index.js CHANGED
@@ -1,4 +1,10 @@
1
1
  // src/field.builder.ts
2
+ function mergeValidatorResult(previousResult, nextValid) {
3
+ if (previousResult !== true) {
4
+ return previousResult;
5
+ }
6
+ return nextValid;
7
+ }
2
8
  var FieldBuilder = class _FieldBuilder {
3
9
  constructor(type, options = {}) {
4
10
  this.type = type;
@@ -6,6 +12,7 @@ var FieldBuilder = class _FieldBuilder {
6
12
  this.itemType = options.itemType;
7
13
  this.refType = options.refType;
8
14
  }
15
+ type;
9
16
  _type;
10
17
  _storageType;
11
18
  isSystem = false;
@@ -94,19 +101,19 @@ var FieldBuilder = class _FieldBuilder {
94
101
  const prevValidator = this._validator;
95
102
  this._validator = (value) => {
96
103
  const valid = typeof value === "number" && value >= min;
97
- return prevValidator ? prevValidator(value) && valid : valid;
104
+ return prevValidator ? mergeValidatorResult(prevValidator(value), valid) : valid;
98
105
  };
99
106
  } else if (this.type === "string") {
100
107
  const prevValidator = this._validator;
101
108
  this._validator = (value) => {
102
109
  const valid = typeof value === "string" && value.length >= min;
103
- return prevValidator ? prevValidator(value) && valid : valid;
110
+ return prevValidator ? mergeValidatorResult(prevValidator(value), valid) : valid;
104
111
  };
105
112
  } else if (this.type === "array") {
106
113
  const prevValidator = this._validator;
107
114
  this._validator = (value) => {
108
115
  const valid = Array.isArray(value) && value.length >= min;
109
- return prevValidator ? prevValidator(value) && valid : valid;
116
+ return prevValidator ? mergeValidatorResult(prevValidator(value), valid) : valid;
110
117
  };
111
118
  } else {
112
119
  throw new Error(
@@ -120,19 +127,19 @@ var FieldBuilder = class _FieldBuilder {
120
127
  const prevValidator = this._validator;
121
128
  this._validator = (value) => {
122
129
  const valid = typeof value === "number" && value <= max;
123
- return prevValidator ? prevValidator(value) && valid : valid;
130
+ return prevValidator ? mergeValidatorResult(prevValidator(value), valid) : valid;
124
131
  };
125
132
  } else if (this.type === "string") {
126
133
  const prevValidator = this._validator;
127
134
  this._validator = (value) => {
128
135
  const valid = typeof value === "string" && value.length <= max;
129
- return prevValidator ? prevValidator(value) && valid : valid;
136
+ return prevValidator ? mergeValidatorResult(prevValidator(value), valid) : valid;
130
137
  };
131
138
  } else if (this.type === "array") {
132
139
  const prevValidator = this._validator;
133
140
  this._validator = (value) => {
134
141
  const valid = Array.isArray(value) && value.length <= max;
135
- return prevValidator ? prevValidator(value) && valid : valid;
142
+ return prevValidator ? mergeValidatorResult(prevValidator(value), valid) : valid;
136
143
  };
137
144
  } else {
138
145
  throw new Error(
@@ -148,7 +155,7 @@ var FieldBuilder = class _FieldBuilder {
148
155
  const prevValidator = this._validator;
149
156
  this._validator = (value) => {
150
157
  const valid = typeof value === "string" && regex.test(value);
151
- return prevValidator ? prevValidator(value) && valid : valid;
158
+ return prevValidator ? mergeValidatorResult(prevValidator(value), valid) : valid;
152
159
  };
153
160
  return this;
154
161
  }
@@ -1547,6 +1554,38 @@ function getValidator(def) {
1547
1554
  function getShape(def) {
1548
1555
  return def?._shape ?? def?.shape ?? void 0;
1549
1556
  }
1557
+ function normalizeValidationIssue(path, issue, defaultCode) {
1558
+ if (typeof issue === "string") {
1559
+ return {
1560
+ path,
1561
+ code: defaultCode,
1562
+ message: issue
1563
+ };
1564
+ }
1565
+ return {
1566
+ path: issue.path ?? path,
1567
+ code: issue.code || defaultCode,
1568
+ message: issue.message
1569
+ };
1570
+ }
1571
+ function normalizeValidatorIssues(path, result, defaultCode) {
1572
+ if (result === true) {
1573
+ return [];
1574
+ }
1575
+ if (result === false) {
1576
+ return [
1577
+ {
1578
+ path,
1579
+ code: defaultCode,
1580
+ message: `Invalid value for field: ${path}`
1581
+ }
1582
+ ];
1583
+ }
1584
+ if (Array.isArray(result)) {
1585
+ return result.map((issue) => normalizeValidationIssue(path, issue, defaultCode));
1586
+ }
1587
+ return [normalizeValidationIssue(path, result, defaultCode)];
1588
+ }
1550
1589
  function checkMissingRequired(parentKey, key, value, def, errors) {
1551
1590
  if (value === void 0 || value === null) {
1552
1591
  const path = parentKey ? `${parentKey}.${key}` : key;
@@ -1565,13 +1604,16 @@ function checkImmutable(parentKey, key, value, def, existing, errors) {
1565
1604
  }
1566
1605
  return { immutableViolation: false };
1567
1606
  }
1568
- function runCustomValidator(parentKey, key, value, def, errors) {
1607
+ function runCustomValidator(parentKey, key, value, def, errors, issues) {
1569
1608
  const validator = getValidator(def);
1570
1609
  if (validator && value !== void 0 && value !== null) {
1571
- const valid = validator(value);
1572
- if (!valid) {
1573
- const path = parentKey ? `${parentKey}.${key}` : key;
1574
- errors.push(`Invalid value for field: ${path}`);
1610
+ const path = parentKey ? `${parentKey}.${key}` : key;
1611
+ const normalizedIssues = normalizeValidatorIssues(path, validator(value), "invalid_value");
1612
+ if (normalizedIssues.length > 0) {
1613
+ errors.push(...normalizedIssues.map((issue) => issue.message));
1614
+ if (issues) {
1615
+ issues.push(...normalizedIssues);
1616
+ }
1575
1617
  return { invalid: true };
1576
1618
  }
1577
1619
  }
@@ -1611,7 +1653,7 @@ function validateBooleanField(parentKey, key, value, _def, errors) {
1611
1653
  errors.push(`Field ${path} must be boolean`);
1612
1654
  }
1613
1655
  }
1614
- function validateObjectChildren(parentKey, obj, shape, errors, existing, piiEnforcement, logger) {
1656
+ function validateObjectChildren(parentKey, obj, shape, errors, issues, existing, piiEnforcement, logger) {
1615
1657
  for (const [childKey, childDef] of Object.entries(shape)) {
1616
1658
  let childValue = obj[childKey];
1617
1659
  const existingChild = existing && typeof existing === "object" ? existing[childKey] : void 0;
@@ -1652,7 +1694,8 @@ function validateObjectChildren(parentKey, obj, shape, errors, existing, piiEnfo
1652
1694
  childKey,
1653
1695
  childValue,
1654
1696
  childDef,
1655
- errors
1697
+ errors,
1698
+ issues
1656
1699
  );
1657
1700
  if (invalid) continue;
1658
1701
  validateByType(
@@ -1661,13 +1704,14 @@ function validateObjectChildren(parentKey, obj, shape, errors, existing, piiEnfo
1661
1704
  childValue,
1662
1705
  childDef,
1663
1706
  errors,
1707
+ issues,
1664
1708
  existingChild,
1665
1709
  piiEnforcement,
1666
1710
  logger
1667
1711
  );
1668
1712
  }
1669
1713
  }
1670
- function validateObjectField(parentKey, key, value, def, errors, existing, piiEnforcement, logger) {
1714
+ function validateObjectField(parentKey, key, value, def, errors, issues, existing, piiEnforcement, logger) {
1671
1715
  const path = parentKey ? `${parentKey}.${key}` : key;
1672
1716
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
1673
1717
  errors.push(`Field ${path} must be object`);
@@ -1675,7 +1719,7 @@ function validateObjectField(parentKey, key, value, def, errors, existing, piiEn
1675
1719
  }
1676
1720
  const objShape = getShape(def);
1677
1721
  if (objShape)
1678
- validateObjectChildren(path, value, objShape, errors, existing, piiEnforcement, logger);
1722
+ validateObjectChildren(path, value, objShape, errors, issues, existing, piiEnforcement, logger);
1679
1723
  }
1680
1724
  function validateArrayOfStrings(parentKey, key, arr, itemDef, errors) {
1681
1725
  const path = parentKey ? `${parentKey}.${key}` : key;
@@ -1734,7 +1778,7 @@ function validateArrayOfBooleans(parentKey, key, arr, _itemDef, errors) {
1734
1778
  });
1735
1779
  }
1736
1780
  }
1737
- function validateArrayOfObjects(parentKey, key, arr, itemDef, errors, existing, piiEnforcement, logger) {
1781
+ function validateArrayOfObjects(parentKey, key, arr, itemDef, errors, issues, existing, piiEnforcement, logger) {
1738
1782
  const path = parentKey ? `${parentKey}.${key}` : key;
1739
1783
  if (!Array.isArray(arr) || !arr.every((v) => typeof v === "object" && v !== null && !Array.isArray(v))) {
1740
1784
  errors.push(`Field ${path} must be object[]`);
@@ -1788,7 +1832,8 @@ function validateArrayOfObjects(parentKey, key, arr, itemDef, errors, existing,
1788
1832
  childKey,
1789
1833
  childValue,
1790
1834
  childDef,
1791
- errors
1835
+ errors,
1836
+ issues
1792
1837
  );
1793
1838
  if (invalid) continue;
1794
1839
  validateByType(
@@ -1797,6 +1842,7 @@ function validateArrayOfObjects(parentKey, key, arr, itemDef, errors, existing,
1797
1842
  childValue,
1798
1843
  childDef,
1799
1844
  errors,
1845
+ issues,
1800
1846
  existingChild,
1801
1847
  piiEnforcement,
1802
1848
  logger
@@ -1804,7 +1850,7 @@ function validateArrayOfObjects(parentKey, key, arr, itemDef, errors, existing,
1804
1850
  }
1805
1851
  });
1806
1852
  }
1807
- function validateArrayField(parentKey, key, value, def, errors, existing, piiEnforcement, logger) {
1853
+ function validateArrayField(parentKey, key, value, def, errors, issues, existing, piiEnforcement, logger) {
1808
1854
  const path = parentKey ? `${parentKey}.${key}` : key;
1809
1855
  if (!Array.isArray(value)) {
1810
1856
  errors.push(`Field ${key} must be an array`);
@@ -1824,6 +1870,7 @@ function validateArrayField(parentKey, key, value, def, errors, existing, piiEnf
1824
1870
  value,
1825
1871
  def.itemType,
1826
1872
  errors,
1873
+ issues,
1827
1874
  existing,
1828
1875
  piiEnforcement,
1829
1876
  logger
@@ -1880,9 +1927,14 @@ function validateArrayField(parentKey, key, value, def, errors, existing, piiEnf
1880
1927
  if (shortCircuit) continue;
1881
1928
  const childValidator = getValidator(childDef);
1882
1929
  if (childValidator && childValue !== void 0 && childValue !== null) {
1883
- const valid = childValidator(childValue);
1884
- if (!valid) {
1885
- errors.push(`Invalid value for field: ${childPath}`);
1930
+ const normalizedIssues = normalizeValidatorIssues(
1931
+ childPath,
1932
+ childValidator(childValue),
1933
+ "invalid_value"
1934
+ );
1935
+ if (normalizedIssues.length > 0) {
1936
+ errors.push(...normalizedIssues.map((issue) => issue.message));
1937
+ issues.push(...normalizedIssues);
1886
1938
  continue;
1887
1939
  }
1888
1940
  }
@@ -1892,6 +1944,7 @@ function validateArrayField(parentKey, key, value, def, errors, existing, piiEnf
1892
1944
  childValue,
1893
1945
  childDef,
1894
1946
  errors,
1947
+ issues,
1895
1948
  existingChild,
1896
1949
  piiEnforcement,
1897
1950
  logger
@@ -1917,7 +1970,7 @@ function validateRefField(parentKey, key, value, def, errors, _existing, _piiEnf
1917
1970
  );
1918
1971
  }
1919
1972
  }
1920
- function validateByType(parentKey, key, value, def, errors, existing, piiEnforcement, logger) {
1973
+ function validateByType(parentKey, key, value, def, errors, issues, existing, piiEnforcement, logger) {
1921
1974
  const path = parentKey ? `${parentKey}.${key}` : key;
1922
1975
  switch (def.type) {
1923
1976
  case "string":
@@ -1933,6 +1986,7 @@ function validateByType(parentKey, key, value, def, errors, existing, piiEnforce
1933
1986
  value,
1934
1987
  def,
1935
1988
  errors,
1989
+ issues,
1936
1990
  existing,
1937
1991
  piiEnforcement,
1938
1992
  logger
@@ -1944,6 +1998,7 @@ function validateByType(parentKey, key, value, def, errors, existing, piiEnforce
1944
1998
  value,
1945
1999
  def,
1946
2000
  errors,
2001
+ issues,
1947
2002
  existing,
1948
2003
  piiEnforcement,
1949
2004
  logger
@@ -1979,6 +2034,7 @@ function createSchema(_shape, entityType, options = {
1979
2034
  // 🔗 Validate input against the schema
1980
2035
  validate(input, existing) {
1981
2036
  const errors = [];
2037
+ const issues = [];
1982
2038
  const result = {};
1983
2039
  const piiMode = options.piiEnforcement ?? "none";
1984
2040
  if (typeof input !== "object" || input === null) {
@@ -2042,16 +2098,19 @@ function createSchema(_shape, entityType, options = {
2042
2098
  if (shortCircuit) continue;
2043
2099
  const validateField = (val) => {
2044
2100
  const localErrors = [];
2101
+ const localIssues = [];
2045
2102
  const { invalid } = runCustomValidator(
2046
2103
  "",
2047
2104
  key,
2048
2105
  val,
2049
2106
  def,
2050
- localErrors
2107
+ localErrors,
2108
+ localIssues
2051
2109
  );
2052
2110
  if (!invalid) {
2053
- validateByType("", key, val, def, localErrors, existingField, piiMode, console);
2111
+ validateByType("", key, val, def, localErrors, localIssues, existingField, piiMode, console);
2054
2112
  }
2113
+ issues.push(...localIssues);
2055
2114
  return localErrors;
2056
2115
  };
2057
2116
  let fieldValue = value;
@@ -2092,7 +2151,8 @@ function createSchema(_shape, entityType, options = {
2092
2151
  return {
2093
2152
  valid: errors.length === 0,
2094
2153
  value: result,
2095
- errors
2154
+ errors,
2155
+ issues
2096
2156
  };
2097
2157
  },
2098
2158
  // specific validator for a schema to allow conditional validation