jsonstat-validator 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
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.
- jsonstat_validator/validator.py +13 -0
- {jsonstat_validator-0.1.2.dist-info → jsonstat_validator-0.1.4.dist-info}/METADATA +3 -1
- jsonstat_validator-0.1.4.dist-info/RECORD +7 -0
- jsonstat_validator-0.1.2.dist-info/RECORD +0 -7
- {jsonstat_validator-0.1.2.dist-info → jsonstat_validator-0.1.4.dist-info}/LICENSE +0 -0
- {jsonstat_validator-0.1.2.dist-info → jsonstat_validator-0.1.4.dist-info}/WHEEL +0 -0
- {jsonstat_validator-0.1.2.dist-info → jsonstat_validator-0.1.4.dist-info}/top_level.txt +0 -0
jsonstat_validator/validator.py
CHANGED
@@ -177,6 +177,19 @@ class Category(JSONStatBaseModel):
|
|
177
177
|
if not self.index and not self.label:
|
178
178
|
raise ValueError("At least one of `index` or `label` is required.")
|
179
179
|
|
180
|
+
# Ensure index and label have the same keys if both are dictionaries
|
181
|
+
if self.index and self.label:
|
182
|
+
if isinstance(self.label, dict):
|
183
|
+
index_keys = (
|
184
|
+
set(self.index)
|
185
|
+
if isinstance(self.index, list)
|
186
|
+
else set(self.index.keys())
|
187
|
+
)
|
188
|
+
if index_keys != set(self.label.keys()):
|
189
|
+
raise ValueError(
|
190
|
+
"Validation error: `index` and `label` must have the same keys."
|
191
|
+
)
|
192
|
+
|
180
193
|
# Ensure coordinates are a dictionary where keys are category IDs
|
181
194
|
# and values are an array of two numbers (longitude, latitude).
|
182
195
|
if self.coordinates:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: jsonstat-validator
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.4
|
4
4
|
Summary: A Python validator for the JSON-stat 2.0 standard format, based on Pydantic.
|
5
5
|
Author-email: Ahmed Hassan <ahmedhassan.ahmed@fao.org>
|
6
6
|
License: # MIT License
|
@@ -76,6 +76,8 @@ Please note that this implementation is intentionally more strict than the offic
|
|
76
76
|
|
77
77
|
This dataset would be considered valid by the official JSON-stat validator tool, but will fail validation in this package because it violates the rule in the `dataset.size` section of the specification stating that: `size has the same number of elements and in the same order as in id`.
|
78
78
|
|
79
|
+
Additionally, we enforce the `role` field as required when `class=dataset`.
|
80
|
+
|
79
81
|
## Table of Contents
|
80
82
|
|
81
83
|
- [Installation](#installation)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
jsonstat_validator/__init__.py,sha256=hvsaEgQFH8vY_bPRDyrhroxjJd1c5nFjmZQ_lxzH0AQ,806
|
2
|
+
jsonstat_validator/validator.py,sha256=HQ5OFKlLSCXevXP44MYb2P9Gm9UbyhacXoMFyE4_3sg,28221
|
3
|
+
jsonstat_validator-0.1.4.dist-info/LICENSE,sha256=cyCvx3tHW8u9ZWGkTMrCKaB2ft4RonlMBVOEHDa2tEk,1091
|
4
|
+
jsonstat_validator-0.1.4.dist-info/METADATA,sha256=vhPhl-4DqzwHywdDThjNYsoWcJaI7krZ8IuBrR4XEnM,7336
|
5
|
+
jsonstat_validator-0.1.4.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
6
|
+
jsonstat_validator-0.1.4.dist-info/top_level.txt,sha256=l6xoMFlWGRRbXMxl4MG-q0FA3In7rYZLBzVF8W7IhdU,19
|
7
|
+
jsonstat_validator-0.1.4.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
jsonstat_validator/__init__.py,sha256=hvsaEgQFH8vY_bPRDyrhroxjJd1c5nFjmZQ_lxzH0AQ,806
|
2
|
-
jsonstat_validator/validator.py,sha256=fhbJBfxq1xsTSuVJ2qBql1p_Y14-yOAgsOLEbubEMQM,27669
|
3
|
-
jsonstat_validator-0.1.2.dist-info/LICENSE,sha256=cyCvx3tHW8u9ZWGkTMrCKaB2ft4RonlMBVOEHDa2tEk,1091
|
4
|
-
jsonstat_validator-0.1.2.dist-info/METADATA,sha256=0PhHVXIpimgPc9-IeaKT4kittcAjydvczeIM7oZgV_M,7259
|
5
|
-
jsonstat_validator-0.1.2.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
6
|
-
jsonstat_validator-0.1.2.dist-info/top_level.txt,sha256=l6xoMFlWGRRbXMxl4MG-q0FA3In7rYZLBzVF8W7IhdU,19
|
7
|
-
jsonstat_validator-0.1.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|