@pdtf/schemas 3.6.0-8 → 3.6.0-9

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/index.js CHANGED
@@ -246,6 +246,18 @@ const getCachedSchemaData = (path, schemaId, overlays) => {
246
246
  matchingProperty = aOneOf.items;
247
247
  } else if (aOneOf.properties?.[pathElement]) {
248
248
  matchingProperty = aOneOf.properties?.[pathElement];
249
+ } else if (aOneOf.patternProperties) {
250
+ for (const pattern in aOneOf.patternProperties) {
251
+ try {
252
+ const regex = new RegExp(pattern);
253
+ if (regex.test(pathElement)) {
254
+ matchingProperty = aOneOf.patternProperties[pattern];
255
+ break;
256
+ }
257
+ } catch (e) {
258
+ // Invalid regex pattern - skip
259
+ }
260
+ }
249
261
  }
250
262
  });
251
263
  if (matchingProperty) return matchingProperty;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "3.6.0-8",
3
+ "version": "3.6.0-9",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -530,6 +530,129 @@ describe("patternProperties support in path validation", () => {
530
530
  });
531
531
  });
532
532
 
533
+ describe("externalIds patternProperties paths", () => {
534
+ test("accepts claim for /externalIds with a nested key path", () => {
535
+ const claim = {
536
+ timestamp: 1643115903108,
537
+ verification: {
538
+ trust_framework: "uk_pdtf",
539
+ time: "2025-01-15T12:00:00Z",
540
+ },
541
+ claims: {
542
+ "/externalIds/nptn/selectedQuoteId": "12345577",
543
+ },
544
+ };
545
+
546
+ const errors = validateVerifiedClaims([claim], schemaId);
547
+ expect(errors).toHaveLength(0);
548
+ });
549
+
550
+ test("accepts claim for /externalIds with a simple string value", () => {
551
+ const claim = {
552
+ timestamp: 1643115903108,
553
+ verification: {
554
+ trust_framework: "uk_pdtf",
555
+ time: "2025-01-15T12:00:00Z",
556
+ },
557
+ claims: {
558
+ "/externalIds/lms": "abc-123",
559
+ },
560
+ };
561
+
562
+ const errors = validateVerifiedClaims([claim], schemaId);
563
+ expect(errors).toHaveLength(0);
564
+ });
565
+
566
+ test("accepts claim for /externalIds with a numeric value", () => {
567
+ const claim = {
568
+ timestamp: 1643115903108,
569
+ verification: {
570
+ trust_framework: "uk_pdtf",
571
+ time: "2025-01-15T12:00:00Z",
572
+ },
573
+ claims: {
574
+ "/externalIds/systemRef": 98765,
575
+ },
576
+ };
577
+
578
+ const errors = validateVerifiedClaims([claim], schemaId);
579
+ expect(errors).toHaveLength(0);
580
+ });
581
+
582
+ test("accepts claim for /externalIds with a boolean value", () => {
583
+ const claim = {
584
+ timestamp: 1643115903108,
585
+ verification: {
586
+ trust_framework: "uk_pdtf",
587
+ time: "2025-01-15T12:00:00Z",
588
+ },
589
+ claims: {
590
+ "/externalIds/isActive": true,
591
+ },
592
+ };
593
+
594
+ const errors = validateVerifiedClaims([claim], schemaId);
595
+ expect(errors).toHaveLength(0);
596
+ });
597
+
598
+ test("accepts claim for /externalIds with an object value", () => {
599
+ const claim = {
600
+ timestamp: 1643115903108,
601
+ verification: {
602
+ trust_framework: "uk_pdtf",
603
+ time: "2025-01-15T12:00:00Z",
604
+ },
605
+ claims: {
606
+ "/externalIds/nptn": {
607
+ selectedQuoteId: "12345577",
608
+ caseRef: "CASE-001",
609
+ },
610
+ },
611
+ };
612
+
613
+ const errors = validateVerifiedClaims([claim], schemaId);
614
+ expect(errors).toHaveLength(0);
615
+ });
616
+
617
+ test("accepts claim with multiple externalIds paths in same claim", () => {
618
+ const claim = {
619
+ timestamp: 1643115903108,
620
+ verification: {
621
+ trust_framework: "uk_pdtf",
622
+ time: "2025-01-15T12:00:00Z",
623
+ },
624
+ claims: {
625
+ "/externalIds/nptn/selectedQuoteId": "12345577",
626
+ "/externalIds/lms": "LMS-REF-001",
627
+ },
628
+ };
629
+
630
+ const errors = validateVerifiedClaims([claim], schemaId);
631
+ expect(errors).toHaveLength(0);
632
+ });
633
+
634
+ test("accepts claim for /externalIds root object", () => {
635
+ const claim = {
636
+ timestamp: 1643115903108,
637
+ verification: {
638
+ trust_framework: "uk_pdtf",
639
+ time: "2025-01-15T12:00:00Z",
640
+ },
641
+ claims: {
642
+ "/externalIds": {
643
+ nptn: {
644
+ selectedQuoteId: "12345577",
645
+ },
646
+ lms: "LMS-REF-001",
647
+ },
648
+ },
649
+ };
650
+
651
+ const errors = validateVerifiedClaims([claim], schemaId);
652
+ expect(errors).toHaveLength(0);
653
+ });
654
+ });
655
+
533
656
  describe("edge cases", () => {
534
657
  test("handles offer ID with dots", () => {
535
658
  const path = "/offers/offer.123.abc";