Skip to content

Commit d2c9870

Browse files
author
Clemens Vasters
committed
Fix instance validation bugs and update validation scripts
Instance fixes: - 06-tuples: Add alpha channel to visualColor tuples (3->4 elements) - 08-namespaces: Restructure examples to match Company/Directory schema - 09-extensions: Fix stray # char, restructure to Fleet schema - 10-discriminated-unions: Add missing fields (transferType, phoneNumber) - 11-sets-and-maps: Fix invalid genre enum values Validation scripts: - Update validate-all.ps1 to use python -m json_structure.* - Update validate-imports.ps1 to use python -m json_structure.* - Add install-validators.ps1 for SDK installation
1 parent 747574d commit d2c9870

File tree

13 files changed

+173
-119
lines changed

13 files changed

+173
-119
lines changed

samples/core/06-tuples/example2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
["2023-11-13T09:00:00Z", "178.000000", 90],
1212
["2023-11-13T10:00:00Z", "145.000000", 88]
1313
],
14-
"visualColor": [255, 0, 0]
14+
"visualColor": [255, 0, 0,0]
1515
}
1616
],
1717
"bounds": [

samples/core/06-tuples/example3.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
"id": "COLOR_SAMPLE_1",
88
"location": ["0.0000000", "0.0000000"],
99
"measurements": [],
10-
"visualColor": [255, 255, 255]
10+
"visualColor": [255, 255, 255, 1.0]
1111
},
1212
{
1313
"id": "COLOR_SAMPLE_2",
1414
"location": ["1.0000000", "1.0000000"],
1515
"measurements": [],
16-
"visualColor": [0, 0, 0]
16+
"visualColor": [0, 0, 0, 1.0]
1717
},
1818
{
1919
"id": "COLOR_SAMPLE_3",
2020
"location": ["0.5000000", "0.5000000"],
2121
"measurements": [],
22-
"visualColor": [128, 128, 128]
22+
"visualColor": [128, 128, 128, 1.0]
2323
}
2424
]
2525
}
Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
11
{
22
"$schema": "https://schemas.example.com/namespaces",
3-
"employee": {
4-
"personalInfo": {
5-
"firstName": "Sarah",
6-
"lastName": "Johnson",
7-
"dateOfBirth": "1985-08-22"
8-
},
9-
"contactInfo": {
10-
"email": "sarah.johnson@company.com",
11-
"phone": "+1-555-987-6543"
12-
},
13-
"workInfo": {
3+
"companyName": "DataFlow Solutions",
4+
"headquarters": {
5+
"street": "500 Tech Boulevard",
6+
"city": "Austin",
7+
"state": "Texas",
8+
"zipCode": "78701",
9+
"country": "US"
10+
},
11+
"employees": [
12+
{
1413
"employeeId": "EMP002",
15-
"department": "Engineering",
14+
"firstName": "Sarah",
15+
"lastName": "Johnson",
16+
"department": {
17+
"code": "ENG",
18+
"name": "Engineering",
19+
"managerId": "EMP001",
20+
"budget": "1800000.00"
21+
},
1622
"position": "Senior Software Developer",
17-
"manager": "John Smith",
18-
"startDate": "2019-03-15",
19-
"salary": "125000.00"
23+
"salary": "125000.00",
24+
"hireDate": "2019-03-15",
25+
"address": {
26+
"street": "789 Maple Lane",
27+
"city": "Austin",
28+
"state": "Texas",
29+
"zipCode": "78702",
30+
"country": "US"
31+
},
32+
"contact": {
33+
"email": "sarah.johnson@company.com",
34+
"phone": "+1-555-987-6543"
35+
}
2036
}
21-
},
22-
"workspaceAssignment": {
23-
"assignmentId": "WS002",
24-
"employeeId": "EMP002",
25-
"assignedDate": "2019-03-20",
26-
"workspace": {
27-
"workspaceId": "WS-3B-15",
28-
"building": "Building B",
29-
"floor": 3,
30-
"room": "3B-15",
31-
"capacity": 1,
32-
"equipment": ["desk", "chair", "monitor", "laptop dock"]
37+
],
38+
"departments": [
39+
{
40+
"code": "ENG",
41+
"name": "Engineering",
42+
"managerId": "EMP001",
43+
"budget": "1800000.00"
3344
}
34-
}
45+
],
46+
"lastUpdated": "2024-11-15T10:30:00Z"
3547
}
Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
11
{
22
"$schema": "https://schemas.example.com/namespaces",
3-
"employee": {
4-
"personalInfo": {
3+
"companyName": "Creative Media Inc",
4+
"headquarters": {
5+
"street": "200 Arts District",
6+
"city": "Los Angeles",
7+
"state": "California",
8+
"zipCode": "90012",
9+
"country": "US"
10+
},
11+
"employees": [
12+
{
13+
"employeeId": "EMP003",
514
"firstName": "Michael",
615
"lastName": "Chen",
7-
"dateOfBirth": "1992-11-03"
8-
},
9-
"contactInfo": {
10-
"email": "michael.chen@company.com",
11-
"phone": "+1-555-234-8901"
12-
},
13-
"workInfo": {
14-
"employeeId": "EMP003",
15-
"department": "Marketing",
16+
"department": {
17+
"code": "MKT",
18+
"name": "Marketing",
19+
"managerId": "EMP001",
20+
"budget": "950000.00"
21+
},
1622
"position": "Marketing Manager",
17-
"manager": "Lisa Brown",
18-
"startDate": "2021-01-10",
19-
"salary": "95000.00"
23+
"salary": "95000.00",
24+
"hireDate": "2021-01-10",
25+
"address": {
26+
"street": "456 Sunset Blvd",
27+
"city": "Los Angeles",
28+
"state": "California",
29+
"zipCode": "90028",
30+
"country": "US"
31+
},
32+
"contact": {
33+
"email": "michael.chen@company.com",
34+
"phone": "+1-555-234-8901"
35+
}
2036
}
21-
},
22-
"workspaceAssignment": {
23-
"assignmentId": "WS003",
24-
"employeeId": "EMP003",
25-
"assignedDate": "2021-01-15",
26-
"workspace": {
27-
"workspaceId": "WS-2A-08",
28-
"building": "Building A",
29-
"floor": 2,
30-
"room": "2A-08",
31-
"capacity": 2,
32-
"equipment": ["desk", "chair", "monitor", "laptop dock", "whiteboard"]
37+
],
38+
"departments": [
39+
{
40+
"code": "MKT",
41+
"name": "Marketing",
42+
"managerId": "EMP001",
43+
"budget": "950000.00"
3344
}
34-
}
45+
],
46+
"lastUpdated": "2024-11-20T14:45:00Z"
3547
}
Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,39 @@
11
{
22
"$schema": "https://schemas.example.com/extensions",
3-
"fleet": [
3+
"fleetName": "Company Fleet 2024",
4+
"totalVehicles": 3,
5+
"lastInventoryDate": "2024-11-15T10:30:00Z",
6+
"trucks": [
47
{
5-
"vehicleId": "TRUCK001",
68
"make": "Ford",
79
"model": "F-150",
810
"year": 2023,
911
"vin": "1FTFW1E50NFB12345",
10-
"licensePlate": "ABC-1234",
11-
"registrationExpiry": "2024-12-31",
12-
"engineType": "V6",
13-
"fuelType": "gasoline",
14-
"payloadCapacity": "1500"
15-
},
12+
"engineType": "gasoline",
13+
"payloadCapacity": 1500,
14+
"commercialLicense": false
15+
}
16+
],
17+
"cars": [
1618
{
17-
"vehicleId": "CAR002",
1819
"make": "Tesla",
1920
"model": "Model 3",
2021
"year": 2024,
2122
"vin": "5YJ3E1EA0KF123456",
22-
"licensePlate": "EV-5678",
23-
"registrationExpiry": "2025-06-30",
2423
"engineType": "electric",
25-
"fuelType": "electric",
26-
"seatingCapacity": 5,
27-
"batteryCapacity": "75"
28-
},
24+
"doors": 4,
25+
"seatingCapacity": 5
26+
}
27+
],
28+
"motorcycles": [
2929
{
30-
"vehicleId": "BIKE001",
3130
"make": "Harley-Davidson",
3231
"model": "Street 750",
3332
"year": 2022,
3433
"vin": "1HD1KB4XXNB123456",
35-
"licensePlate": "BIKE-99",
36-
"registrationExpiry": "2024-08-15",
37-
"engineType": "V-Twin",
38-
"fuelType": "gasoline",
39-
"engineDisplacement": "749"
34+
"engineType": "gasoline",
35+
"engineSize": 749,
36+
"style": "cruiser"
4037
}
4138
]
4239
}
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
{
22
"$schema": "https://schemas.example.com/extensions",
3-
"fleet": [
3+
"fleetName": "Luxury & Work Fleet",
4+
"totalVehicles": 2,
5+
"lastInventoryDate": "2024-11-20T09:00:00Z",
6+
"cars": [
47
{
5-
"vehicleId": "CAR003",
68
"make": "BMW",
79
"model": "X5",
810
"year": 2023,
911
"vin": "5UXCR6C0XN9123456",
10-
"licensePlate": "LUX-2024",
11-
"registrationExpiry": "2025-03-31",
12-
"engineType": "turbo-inline-6",
13-
"fuelType": "gasoline",
14-
"seatingCapacity": 7,
15-
"drivetrain": "AWD"
16-
},
12+
"engineType": "gasoline",
13+
"doors": 4,
14+
"seatingCapacity": 7
15+
}
16+
],
17+
"trucks": [
1718
{
18-
"vehicleId": "TRUCK002",
1919
"make": "Chevrolet",
2020
"model": "Silverado 2500HD",
2121
"year": 2024,
2222
"vin": "1GC4YPEY6NF123456",
23-
"licensePlate": "WORK-789",
24-
"registrationExpiry": "2025-09-30",
25-
"engineType": "V8",
26-
"fuelType": "diesel",
27-
"payloadCapacity": "3500",
28-
"towingCapacity": "18500"
23+
"engineType": "diesel",
24+
"payloadCapacity": 3500,
25+
"commercialLicense": true
2926
}
3027
]
3128
}

samples/core/10-discriminated-unions/example2.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"accountNumber": "*****6789",
1212
"routingNumber": "021000021",
1313
"accountHolderName": "Jane Doe",
14-
"transferReference": "REF123456789"
14+
"transferType": "wire",
15+
"referenceNumber": "REF123456789"
1516
}
1617
},
1718
"status": "pending",
@@ -21,7 +22,8 @@
2122
"priority": "high",
2223
"recipient": "+1-555-123-4567",
2324
"notificationType": "sms",
24-
"message": "Payment of $89.50 is being processed. You'll receive confirmation soon."
25+
"message": "Payment of $89.50 is being processed.",
26+
"phoneNumber": "+1-555-123-4567"
2527
},
2628
"processedAt": "2023-11-13T16:20:15Z",
2729
"fees": {

samples/core/10-discriminated-unions/example3.json

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,20 @@
77
"description": "Digital gift card purchase",
88
"paymentMethod": {
99
"digitalWallet": {
10-
"walletProvider": "PayPal",
11-
"walletId": "user@example.com",
12-
"transactionId": "PP123456789",
13-
"walletBalance": "150.75"
10+
"walletProvider": "paypal",
11+
"walletAccountId": "user@example.com",
12+
"transactionId": "PP123456789"
1413
}
1514
},
16-
"status": "completed",
15+
"status": "captured",
1716
"notification": {
1817
"notificationId": "550e8400-e29b-41d4-a716-446655440006",
1918
"timestamp": "2023-11-13T17:10:45Z",
2019
"priority": "normal",
2120
"recipient": "admin@merchantstore.com",
22-
"notificationType": "webhook",
23-
"webhookUrl": "https://api.merchantstore.com/webhooks/payment",
24-
"webhookPayload": {
25-
"event": "payment.completed",
26-
"transactionId": "550e8400-e29b-41d4-a716-446655440005",
27-
"amount": "25.00"
28-
}
21+
"notificationType": "email",
22+
"subject": "Payment Completed",
23+
"body": "Your payment of $25.00 for a digital gift card has been processed successfully."
2924
},
3025
"processedAt": "2023-11-13T17:10:45Z",
3126
"fees": {

samples/core/11-sets-and-maps/example1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"isbn": "978-0-7475-3269-9",
3333
"title": "Harry Potter and the Philosopher's Stone",
3434
"authors": ["550e8400-e29b-41d4-a716-446655440003"],
35-
"genres": ["fiction", "fantasy"],
35+
"genres": ["fiction", "mystery"],
3636
"publishYear": 1997,
3737
"pageCount": 223,
3838
"ratings": {

samples/core/11-sets-and-maps/example3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"isbn": "978-1-4028-9462-6",
88
"title": "A Brief History of Time",
99
"authors": ["550e8400-e29b-41d4-a716-446655440006"],
10-
"genres": ["non-fiction", "science"],
10+
"genres": ["non-fiction", "technical"],
1111
"publishYear": 1988,
1212
"pageCount": 256,
1313
"ratings": {

0 commit comments

Comments
 (0)