@squiz/dx-json-schema-lib 1.34.1-alpha.0 → 1.34.1-alpha.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,10 @@ import {
13
13
  ResolvableType,
14
14
  TypeResolver,
15
15
  } from './jsonTypeResolution/TypeResolver';
16
- import { FormattedTextType, SquizImageType } from './primitiveTypes';
16
+ import { FormattedTextType, SquizImageType, SquizLinkType } from './primitiveTypes';
17
+ import { TypeResolverBuilder } from './jsonTypeResolution/TypeResolverBuilder';
18
+ import { MatrixAssetUri } from './validators/utils/matrixAssetValidator';
19
+ import { MatrixAssetType } from './resolvableTypes';
17
20
 
18
21
  function expectToThrowErrorMatchingTypeAndMessage(
19
22
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -153,22 +156,32 @@ describe('JsonValidationService', () => {
153
156
  });
154
157
  },
155
158
  SchemaValidationError,
156
- `failed validation: matrix asset uri "not-valid://canary uat matrix.squiz.cloud//abc123" isn't a valid matrix asset uri`,
159
+ 'failed validation: Value matrix-asset-uri (not-valid://canary uat matrix.squiz.cloud//abc123) in `#/matrix-asset` is not a valid matrix asset uri',
157
160
  {
158
- '#/matrix-asset': {
159
- assetId: {
160
- data: { expected: /^\d+(?::.+)?$/, received: '/abc123' },
161
- message: 'Matrix Asset Id has invalid format, must match /^d+(?::.+)?$/',
162
- },
163
- identifier: {
164
- data: { expected: /^[a-zA-Z0-9.-]+$/, received: 'canary uat matrix.squiz.cloud' },
165
- message: 'Matrix Identifier has invalid format, must match /^[a-zA-Z0-9.-]+$/',
166
- },
167
- scheme: {
168
- data: { expected: 'matrix-asset', received: 'not-valid' },
169
- message: 'Uri scheme is invalid, must match "matrix-asset"',
161
+ '#/matrix-asset': [
162
+ {
163
+ data: {
164
+ errors: {
165
+ assetId: {
166
+ data: { expected: /^\d+(?::.+)?$/, received: '/abc123' },
167
+ message: 'Matrix Asset Id has invalid format, must match /^d+(?::.+)?$/',
168
+ },
169
+ identifier: {
170
+ data: { expected: /^[a-zA-Z0-9.-]+$/, received: 'canary uat matrix.squiz.cloud' },
171
+ message: 'Matrix Identifier has invalid format, must match /^[a-zA-Z0-9.-]+$/',
172
+ },
173
+ scheme: {
174
+ data: { expected: 'matrix-asset', received: 'not-valid' },
175
+ message: 'Uri scheme is invalid, must match "matrix-asset"',
176
+ },
177
+ },
178
+ pointer: '#/matrix-asset',
179
+ value: 'not-valid://canary uat matrix.squiz.cloud//abc123',
180
+ },
181
+ message:
182
+ 'Value matrix-asset-uri (not-valid://canary uat matrix.squiz.cloud//abc123) in `#/matrix-asset` is not a valid matrix asset uri',
170
183
  },
171
- },
184
+ ],
172
185
  },
173
186
  );
174
187
  });
@@ -201,22 +214,31 @@ describe('JsonValidationService', () => {
201
214
  });
202
215
  },
203
216
  SchemaValidationError,
204
- `failed validation: matrix asset uri "matrix://" isn't a valid matrix asset uri`,
217
+ 'failed validation: Value matrix-asset-uri (matrix://) in `#/matrix-asset` is not a valid matrix asset uri',
205
218
  {
206
- '#/matrix-asset': {
207
- assetId: {
208
- data: { expected: /^\d+(?::.+)?$/, received: '' },
209
- message: 'Matrix Asset Id has invalid format, must match /^d+(?::.+)?$/',
210
- },
211
- identifier: {
212
- data: { expected: /^[a-zA-Z0-9.-]+$/, received: '' },
213
- message: 'Matrix Identifier has invalid format, must match /^[a-zA-Z0-9.-]+$/',
214
- },
215
- scheme: {
216
- data: { expected: 'matrix-asset', received: 'matrix' },
217
- message: 'Uri scheme is invalid, must match "matrix-asset"',
219
+ '#/matrix-asset': [
220
+ {
221
+ data: {
222
+ errors: {
223
+ assetId: {
224
+ data: { expected: /^\d+(?::.+)?$/, received: '' },
225
+ message: 'Matrix Asset Id has invalid format, must match /^d+(?::.+)?$/',
226
+ },
227
+ identifier: {
228
+ data: { expected: /^[a-zA-Z0-9.-]+$/, received: '' },
229
+ message: 'Matrix Identifier has invalid format, must match /^[a-zA-Z0-9.-]+$/',
230
+ },
231
+ scheme: {
232
+ data: { expected: 'matrix-asset', received: 'matrix' },
233
+ message: 'Uri scheme is invalid, must match "matrix-asset"',
234
+ },
235
+ },
236
+ pointer: '#/matrix-asset',
237
+ value: 'matrix://',
238
+ },
239
+ message: 'Value matrix-asset-uri (matrix://) in `#/matrix-asset` is not a valid matrix asset uri',
218
240
  },
219
- },
241
+ ],
220
242
  },
221
243
  );
222
244
  });
@@ -1374,3 +1396,542 @@ describe('JsonSchemaService', () => {
1374
1396
  });
1375
1397
  });
1376
1398
  });
1399
+
1400
+ describe('JSONSchemaService - validation', () => {
1401
+ const typeResolver = TypeResolverBuilder.new()
1402
+ .addPrimitive(SquizImageType)
1403
+ .addPrimitive(SquizLinkType)
1404
+ .addPrimitive(FormattedTextType)
1405
+ .build();
1406
+
1407
+ const jsonSchemaService = new JSONSchemaService(typeResolver, ComponentInputMetaSchema);
1408
+
1409
+ it('should validate a schema with all the squiz primitive types', () => {
1410
+ const schema = {
1411
+ type: 'object',
1412
+ properties: {
1413
+ image: { type: 'SquizImage' },
1414
+ link: { type: 'SquizLink' },
1415
+ text: { type: 'FormattedText' },
1416
+ },
1417
+ required: ['image', 'link', 'text'],
1418
+ };
1419
+ const formattedText: FormattedText = [
1420
+ {
1421
+ tag: 'p',
1422
+ type: 'tag',
1423
+ children: [{ type: 'text', value: 'hello' }],
1424
+ },
1425
+ ];
1426
+ const input: {
1427
+ image: SquizImageType['__shape__'];
1428
+ link: SquizLinkType['__shape__'];
1429
+ text: FormattedText;
1430
+ } = {
1431
+ image: {
1432
+ name: 'test-image.jpeg',
1433
+ imageVariations: {
1434
+ original: {
1435
+ aspectRatio: '1:1',
1436
+ height: 100,
1437
+ width: 100,
1438
+ url: 'https://www.squiz.net',
1439
+ byteSize: 100,
1440
+ mimeType: 'image/jpeg',
1441
+ sha1Hash: '123',
1442
+ },
1443
+ },
1444
+ },
1445
+ link: {
1446
+ name: 'test-link',
1447
+ url: 'https://www.squiz.net',
1448
+ target: '_blank',
1449
+ },
1450
+ text: formattedText,
1451
+ };
1452
+
1453
+ const result = jsonSchemaService.validateInput(input, schema);
1454
+
1455
+ expect(result).toEqual(true);
1456
+ });
1457
+
1458
+ it('should validate a schema with all the squiz primitive types and matrix-asset-uri format', () => {
1459
+ const schema = {
1460
+ type: 'object',
1461
+ properties: {
1462
+ image: { type: 'SquizImage' },
1463
+ link: { type: 'SquizLink' },
1464
+ text: { type: 'FormattedText' },
1465
+ asset: {
1466
+ type: 'string',
1467
+ format: 'matrix-asset-uri',
1468
+ },
1469
+ },
1470
+ required: ['image', 'link', 'text', 'asset'],
1471
+ };
1472
+ const formattedText: FormattedText = [
1473
+ {
1474
+ tag: 'p',
1475
+ type: 'tag',
1476
+ children: [{ type: 'text', value: 'hello' }],
1477
+ },
1478
+ ];
1479
+ const input: {
1480
+ image: SquizImageType['__shape__'];
1481
+ link: SquizLinkType['__shape__'];
1482
+ text: FormattedText;
1483
+ asset: MatrixAssetUri;
1484
+ } = {
1485
+ image: {
1486
+ name: 'test-image.jpeg',
1487
+ imageVariations: {
1488
+ original: {
1489
+ aspectRatio: '1:1',
1490
+ height: 100,
1491
+ width: 100,
1492
+ url: 'https://www.squiz.net',
1493
+ byteSize: 100,
1494
+ mimeType: 'image/jpeg',
1495
+ sha1Hash: '123',
1496
+ },
1497
+ },
1498
+ },
1499
+ link: {
1500
+ name: 'test-link',
1501
+ url: 'https://www.squiz.net',
1502
+ target: '_blank',
1503
+ },
1504
+ text: formattedText,
1505
+ asset: 'matrix-asset://identifier/123',
1506
+ };
1507
+
1508
+ const result = jsonSchemaService.validateInput(input, schema);
1509
+
1510
+ expect(result).toEqual(true);
1511
+ });
1512
+
1513
+ it('should catch validation errors when there is a schema with all the squiz primitive types', () => {
1514
+ const schema = {
1515
+ type: 'object',
1516
+ properties: {
1517
+ image: { type: 'SquizImage' },
1518
+ link: { type: 'SquizLink' },
1519
+ text: { type: 'FormattedText' },
1520
+ },
1521
+ required: ['image', 'link', 'text'],
1522
+ };
1523
+ const formattedText: FormattedText = [
1524
+ //@ts-expect-error - wrong type
1525
+ {
1526
+ children: [{ type: 'text', value: 'hello' }],
1527
+ },
1528
+ ];
1529
+ const input: {
1530
+ image: SquizImageType['__shape__'];
1531
+ link: SquizLinkType['__shape__'];
1532
+ text: FormattedText;
1533
+ } = {
1534
+ image: {
1535
+ name: 'test-image.jpeg',
1536
+ imageVariations: {
1537
+ //@ts-expect-error - wrong type
1538
+ original: {
1539
+ width: 100,
1540
+ url: 'https://www.squiz.net',
1541
+ byteSize: 100,
1542
+ mimeType: 'image/jpeg',
1543
+ sha1Hash: '123',
1544
+ },
1545
+ },
1546
+ },
1547
+ //@ts-expect-error - wrong type
1548
+ link: {
1549
+ name: 'test-link',
1550
+ target: '_blank',
1551
+ },
1552
+ text: formattedText,
1553
+ };
1554
+
1555
+ expectToThrowErrorMatchingTypeAndMessage(
1556
+ () => jsonSchemaService.validateInput(input, schema),
1557
+ SchemaValidationError,
1558
+ 'failed validation: Value `{"name":"test-image.jpeg","imageVariations":{"original":{"width":100,"url":"https://www.squiz.net","byteSize":100,"mimeType":"image/jpeg","sha1Hash":"123"}}}` in `#/image` does not match any given oneof schema,\nValue `{"name":"test-link","target":"_blank"}` in `#/link` does not match any given oneof schema,\nValue `[{"children":[{"type":"text","value":"hello"}]}]` in `#/text` does not match any given oneof schema',
1559
+ {
1560
+ '#/image': [
1561
+ {
1562
+ data: {
1563
+ errors: [
1564
+ {
1565
+ code: 'required-property-error',
1566
+ data: { key: 'height', pointer: '#/image/imageVariations/original' },
1567
+ message: 'The required property `height` is missing at `#/image/imageVariations/original`',
1568
+ name: 'RequiredPropertyError',
1569
+ type: 'error',
1570
+ },
1571
+ {
1572
+ code: 'required-property-error',
1573
+ data: { key: 'aspectRatio', pointer: '#/image/imageVariations/original' },
1574
+ message: 'The required property `aspectRatio` is missing at `#/image/imageVariations/original`',
1575
+ name: 'RequiredPropertyError',
1576
+ type: 'error',
1577
+ },
1578
+ ],
1579
+ oneOf: [{ $ref: 'SquizImage.json' }],
1580
+ pointer: '#/image',
1581
+ value:
1582
+ '{"name":"test-image.jpeg","imageVariations":{"original":{"width":100,"url":"https://www.squiz.net","byteSize":100,"mimeType":"image/jpeg","sha1Hash":"123"}}}',
1583
+ },
1584
+ message:
1585
+ 'Value `{"name":"test-image.jpeg","imageVariations":{"original":{"width":100,"url":"https://www.squiz.net","byteSize":100,"mimeType":"image/jpeg","sha1Hash":"123"}}}` in `#/image` does not match any given oneof schema',
1586
+ },
1587
+ ],
1588
+ '#/link': [
1589
+ {
1590
+ data: {
1591
+ errors: [
1592
+ {
1593
+ code: 'required-property-error',
1594
+ data: { key: 'url', pointer: '#/link' },
1595
+ message: 'The required property `url` is missing at `#/link`',
1596
+ name: 'RequiredPropertyError',
1597
+ type: 'error',
1598
+ },
1599
+ ],
1600
+ oneOf: [{ $ref: 'SquizLink.json' }],
1601
+ pointer: '#/link',
1602
+ value: '{"name":"test-link","target":"_blank"}',
1603
+ },
1604
+ message: 'Value `{"name":"test-link","target":"_blank"}` in `#/link` does not match any given oneof schema',
1605
+ },
1606
+ ],
1607
+ '#/text': [
1608
+ {
1609
+ data: {
1610
+ errors: [
1611
+ {
1612
+ code: 'any-of-error',
1613
+ data: {
1614
+ anyOf: [
1615
+ { $ref: '#/definitions/HigherOrderFormattedNodes' },
1616
+ { $ref: '#/definitions/BaseFormattedNodes' },
1617
+ ],
1618
+ pointer: '#/text/0',
1619
+ value: { children: [{ type: 'text', value: 'hello' }] },
1620
+ },
1621
+ message: 'Object at `#/text/0` does not match any schema',
1622
+ name: 'AnyOfError',
1623
+ type: 'error',
1624
+ },
1625
+ ],
1626
+ oneOf: [{ $ref: 'FormattedText.json' }],
1627
+ pointer: '#/text',
1628
+ value: '[{"children":[{"type":"text","value":"hello"}]}]',
1629
+ },
1630
+ message:
1631
+ 'Value `[{"children":[{"type":"text","value":"hello"}]}]` in `#/text` does not match any given oneof schema',
1632
+ },
1633
+ ],
1634
+ },
1635
+ );
1636
+ });
1637
+
1638
+ it('should catch validation errors when invalid matrix-asset-uri is provided with invalid other squiz primitive types ', () => {
1639
+ const schema = {
1640
+ type: 'object',
1641
+ properties: {
1642
+ image: { type: 'SquizImage' },
1643
+ link: { type: 'SquizLink' },
1644
+ text: { type: 'FormattedText' },
1645
+ asset: {
1646
+ type: 'string',
1647
+ format: 'matrix-asset-uri',
1648
+ },
1649
+ },
1650
+
1651
+ required: ['image', 'link', 'text', 'asset'],
1652
+ };
1653
+ const formattedText: FormattedText = [
1654
+ //@ts-expect-error - wrong type
1655
+ {
1656
+ children: [{ type: 'text', value: 'hello' }],
1657
+ },
1658
+ ];
1659
+ const input: {
1660
+ image: SquizImageType['__shape__'];
1661
+ link: SquizLinkType['__shape__'];
1662
+ text: FormattedText;
1663
+ asset: MatrixAssetUri;
1664
+ } = {
1665
+ image: {
1666
+ name: 'test-image.jpeg',
1667
+ imageVariations: {
1668
+ //@ts-expect-error - wrong type
1669
+ original: {
1670
+ width: 100,
1671
+ url: 'https://www.squiz.net',
1672
+ byteSize: 100,
1673
+ mimeType: 'image/jpeg',
1674
+ sha1Hash: '123',
1675
+ },
1676
+ },
1677
+ },
1678
+ //@ts-expect-error - wrong type
1679
+ link: {
1680
+ name: 'test-link',
1681
+ target: '_blank',
1682
+ },
1683
+ text: formattedText,
1684
+ // @ts-expect-error - wrong type
1685
+ asset: 'matrix://123',
1686
+ };
1687
+
1688
+ expectToThrowErrorMatchingTypeAndMessage(
1689
+ () => jsonSchemaService.validateInput(input, schema),
1690
+ SchemaValidationError,
1691
+ 'failed validation: Value `{"name":"test-image.jpeg","imageVariations":{"original":{"width":100,"url":"https://www.squiz.net","byteSize":100,"mimeType":"image/jpeg","sha1Hash":"123"}}}` in `#/image` does not match any given oneof schema,\nValue `{"name":"test-link","target":"_blank"}` in `#/link` does not match any given oneof schema,\nValue `[{"children":[{"type":"text","value":"hello"}]}]` in `#/text` does not match any given oneof schema,\nValue matrix-asset-uri (matrix://123) in `#/asset` is not a valid matrix asset uri',
1692
+ {
1693
+ '#/asset': [
1694
+ {
1695
+ data: {
1696
+ errors: {
1697
+ assetId: {
1698
+ data: { expected: /^\d+(?::.+)?$/, received: '' },
1699
+ message: 'Matrix Asset Id has invalid format, must match /^d+(?::.+)?$/',
1700
+ },
1701
+ scheme: {
1702
+ data: { expected: 'matrix-asset', received: 'matrix' },
1703
+ message: 'Uri scheme is invalid, must match "matrix-asset"',
1704
+ },
1705
+ },
1706
+ pointer: '#/asset',
1707
+ value: 'matrix://123',
1708
+ },
1709
+ message: 'Value matrix-asset-uri (matrix://123) in `#/asset` is not a valid matrix asset uri',
1710
+ },
1711
+ ],
1712
+ '#/image': [
1713
+ {
1714
+ data: {
1715
+ errors: [
1716
+ {
1717
+ code: 'required-property-error',
1718
+ data: { key: 'height', pointer: '#/image/imageVariations/original' },
1719
+ message: 'The required property `height` is missing at `#/image/imageVariations/original`',
1720
+ name: 'RequiredPropertyError',
1721
+ type: 'error',
1722
+ },
1723
+ {
1724
+ code: 'required-property-error',
1725
+ data: { key: 'aspectRatio', pointer: '#/image/imageVariations/original' },
1726
+ message: 'The required property `aspectRatio` is missing at `#/image/imageVariations/original`',
1727
+ name: 'RequiredPropertyError',
1728
+ type: 'error',
1729
+ },
1730
+ ],
1731
+ oneOf: [{ $ref: 'SquizImage.json' }],
1732
+ pointer: '#/image',
1733
+ value:
1734
+ '{"name":"test-image.jpeg","imageVariations":{"original":{"width":100,"url":"https://www.squiz.net","byteSize":100,"mimeType":"image/jpeg","sha1Hash":"123"}}}',
1735
+ },
1736
+ message:
1737
+ 'Value `{"name":"test-image.jpeg","imageVariations":{"original":{"width":100,"url":"https://www.squiz.net","byteSize":100,"mimeType":"image/jpeg","sha1Hash":"123"}}}` in `#/image` does not match any given oneof schema',
1738
+ },
1739
+ ],
1740
+ '#/link': [
1741
+ {
1742
+ data: {
1743
+ errors: [
1744
+ {
1745
+ code: 'required-property-error',
1746
+ data: { key: 'url', pointer: '#/link' },
1747
+ message: 'The required property `url` is missing at `#/link`',
1748
+ name: 'RequiredPropertyError',
1749
+ type: 'error',
1750
+ },
1751
+ ],
1752
+ oneOf: [{ $ref: 'SquizLink.json' }],
1753
+ pointer: '#/link',
1754
+ value: '{"name":"test-link","target":"_blank"}',
1755
+ },
1756
+ message: 'Value `{"name":"test-link","target":"_blank"}` in `#/link` does not match any given oneof schema',
1757
+ },
1758
+ ],
1759
+ '#/text': [
1760
+ {
1761
+ data: {
1762
+ errors: [
1763
+ {
1764
+ code: 'any-of-error',
1765
+ data: {
1766
+ anyOf: [
1767
+ { $ref: '#/definitions/HigherOrderFormattedNodes' },
1768
+ { $ref: '#/definitions/BaseFormattedNodes' },
1769
+ ],
1770
+ pointer: '#/text/0',
1771
+ value: { children: [{ type: 'text', value: 'hello' }] },
1772
+ },
1773
+ message: 'Object at `#/text/0` does not match any schema',
1774
+ name: 'AnyOfError',
1775
+ type: 'error',
1776
+ },
1777
+ ],
1778
+ oneOf: [{ $ref: 'FormattedText.json' }],
1779
+ pointer: '#/text',
1780
+ value: '[{"children":[{"type":"text","value":"hello"}]}]',
1781
+ },
1782
+ message:
1783
+ 'Value `[{"children":[{"type":"text","value":"hello"}]}]` in `#/text` does not match any given oneof schema',
1784
+ },
1785
+ ],
1786
+ },
1787
+ );
1788
+ });
1789
+
1790
+ it('should validate when MatrixAssetType is being used for a squiz primitive type with resolver', () => {
1791
+ const typeResolver = TypeResolverBuilder.new()
1792
+ .addPrimitive(SquizImageType)
1793
+ .addPrimitive(SquizLinkType)
1794
+ .addPrimitive(FormattedTextType)
1795
+ .addResolver(SquizImageType, MatrixAssetType, (): SquizImageType['__shape__'] => {
1796
+ return {
1797
+ name: '',
1798
+ imageVariations: {
1799
+ original: {
1800
+ width: 0,
1801
+ height: 0,
1802
+ url: '',
1803
+ mimeType: '',
1804
+ byteSize: 0,
1805
+ sha1Hash: '',
1806
+ aspectRatio: '',
1807
+ },
1808
+ },
1809
+ };
1810
+ })
1811
+ .build();
1812
+
1813
+ const jsonSchemaService = new JSONSchemaService(typeResolver, ComponentInputMetaSchema);
1814
+ const schema = {
1815
+ type: 'object',
1816
+ properties: {
1817
+ image: { type: 'SquizImage' },
1818
+ link: { type: 'SquizLink' },
1819
+ text: { type: 'FormattedText' },
1820
+ asset: {
1821
+ type: 'string',
1822
+ format: 'matrix-asset-uri',
1823
+ },
1824
+ },
1825
+ required: ['image', 'link', 'text', 'asset'],
1826
+ };
1827
+ const formattedText: FormattedText = [
1828
+ {
1829
+ tag: 'p',
1830
+ type: 'tag',
1831
+ children: [{ type: 'text', value: 'hello' }],
1832
+ },
1833
+ ];
1834
+ const input: {
1835
+ image: MatrixAssetType['__shape__'];
1836
+ link: SquizLinkType['__shape__'];
1837
+ text: FormattedText;
1838
+ asset: MatrixAssetUri;
1839
+ } = {
1840
+ image: {
1841
+ matrixAssetId: '123',
1842
+ matrixIdentifier: 'identifier',
1843
+ matrixDomain: 'domain',
1844
+ },
1845
+ link: {
1846
+ name: 'test-link',
1847
+ url: 'https://www.squiz.net',
1848
+ target: '_blank',
1849
+ },
1850
+ text: formattedText,
1851
+ asset: 'matrix-asset://identifier/123',
1852
+ };
1853
+
1854
+ expect(jsonSchemaService.validateInput(input, schema)).toEqual(true);
1855
+ });
1856
+
1857
+ it('it should catch MatrixAssetType validation errors when being use for squiz primitive type with resolver', () => {
1858
+ const typeResolver = TypeResolverBuilder.new()
1859
+ .addPrimitive(SquizImageType)
1860
+ .addPrimitive(SquizLinkType)
1861
+ .addPrimitive(FormattedTextType)
1862
+ .addResolver(SquizImageType, MatrixAssetType, (): SquizImageType['__shape__'] => {
1863
+ return {
1864
+ name: '',
1865
+ imageVariations: {
1866
+ original: {
1867
+ width: 0,
1868
+ height: 0,
1869
+ url: '',
1870
+ mimeType: '',
1871
+ byteSize: 0,
1872
+ sha1Hash: '',
1873
+ aspectRatio: '',
1874
+ },
1875
+ },
1876
+ };
1877
+ })
1878
+ .build();
1879
+
1880
+ const jsonSchemaService = new JSONSchemaService(typeResolver, ComponentInputMetaSchema);
1881
+ const schema = {
1882
+ type: 'object',
1883
+ properties: {
1884
+ image: { type: 'SquizImage' },
1885
+ },
1886
+ required: ['image'],
1887
+ };
1888
+ const input: {
1889
+ image: MatrixAssetType['__shape__'];
1890
+ } = {
1891
+ //@ts-expect-error - intentionally invalid input
1892
+ image: {
1893
+ matrixIdentifier: 'identifier',
1894
+ },
1895
+ };
1896
+ expectToThrowErrorMatchingTypeAndMessage(
1897
+ () => jsonSchemaService.validateInput(input, schema),
1898
+ SchemaValidationError,
1899
+ 'failed validation: Value `{"matrixIdentifier":"identifier"}` in `#/image` does not match any given oneof schema',
1900
+ {
1901
+ '#/image': [
1902
+ {
1903
+ data: {
1904
+ errors: [
1905
+ {
1906
+ code: 'required-property-error',
1907
+ data: { key: 'name', pointer: '#/image' },
1908
+ message: 'The required property `name` is missing at `#/image`',
1909
+ name: 'RequiredPropertyError',
1910
+ type: 'error',
1911
+ },
1912
+ {
1913
+ code: 'required-property-error',
1914
+ data: { key: 'imageVariations', pointer: '#/image' },
1915
+ message: 'The required property `imageVariations` is missing at `#/image`',
1916
+ name: 'RequiredPropertyError',
1917
+ type: 'error',
1918
+ },
1919
+ {
1920
+ code: 'required-property-error',
1921
+ data: { key: 'matrixAssetId', pointer: '#/image' },
1922
+ message: 'The required property `matrixAssetId` is missing at `#/image`',
1923
+ name: 'RequiredPropertyError',
1924
+ type: 'error',
1925
+ },
1926
+ ],
1927
+ oneOf: [{ $ref: 'SquizImage.json' }, { $ref: 'MatrixAsset.json' }],
1928
+ pointer: '#/image',
1929
+ value: '{"matrixIdentifier":"identifier"}',
1930
+ },
1931
+ message: 'Value `{"matrixIdentifier":"identifier"}` in `#/image` does not match any given oneof schema',
1932
+ },
1933
+ ],
1934
+ },
1935
+ );
1936
+ });
1937
+ });