@sinclair/typebox 0.34.37 → 0.34.38

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.
@@ -196,6 +196,13 @@ function FromUndefined(schema, references, value) {
196
196
  return TryConvertUndefined(value);
197
197
  }
198
198
  function FromUnion(schema, references, value) {
199
+ // Check if original value already matches one of the union variants
200
+ for (const subschema of schema.anyOf) {
201
+ if ((0, index_2.Check)(subschema, references, value)) {
202
+ return value;
203
+ }
204
+ }
205
+ // Attempt conversion for each variant
199
206
  for (const subschema of schema.anyOf) {
200
207
  const converted = Visit(subschema, references, (0, index_1.Clone)(value));
201
208
  if (!(0, index_2.Check)(subschema, references, converted))
@@ -192,6 +192,13 @@ function FromUndefined(schema, references, value) {
192
192
  return TryConvertUndefined(value);
193
193
  }
194
194
  function FromUnion(schema, references, value) {
195
+ // Check if original value already matches one of the union variants
196
+ for (const subschema of schema.anyOf) {
197
+ if (Check(subschema, references, value)) {
198
+ return value;
199
+ }
200
+ }
201
+ // Attempt conversion for each variant
195
202
  for (const subschema of schema.anyOf) {
196
203
  const converted = Visit(subschema, references, Clone(value));
197
204
  if (!Check(subschema, references, converted))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.34.37",
3
+ "version": "0.34.38",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",