Skip to content

Commit 9059a14

Browse files
committed
Added error to the validator
1 parent dd5a965 commit 9059a14

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88

99
if __name__ == '__main__':
1010
validator = OSWValidation(schema_dir=SCHEMA_DIR)
11-
validator.validate()
11+
is_valid = validator.validate()
12+
if is_valid is False:
13+
print(validator.errors)

src/python_lib_osw_validation/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def __init__(self, schema_dir: str):
1010
self.schema_dir = schema_dir
1111
self.schema = self.load_osw_schema(Path(self.schema_dir, 'opensidewalks.schema.json'))
1212
self.region_id = 'wa.microsoft'
13+
self.errors = None
1314

1415
def load_osw_schema(self, schema_path: str) -> Dict[str, Any]:
1516
"""Load OSW Schema"""
@@ -32,11 +33,12 @@ def validate_osw_errors(self, geojson_data: Dict[str, Any]) -> bool:
3233
for error in errors:
3334
error_count += 1
3435
# Format and store in file for further review
35-
print(error)
36+
self.errors = error
3637

3738
return error_count == 0
3839

3940
def validate(self) -> None:
41+
self.errors = None
4042
# Validate edges
4143
is_valid = self.validate_osw_errors(
4244
self.load_osw_file(Path(self.schema_dir, f"{self.region_id}.graph.edges.OSW.geojson")))

0 commit comments

Comments
 (0)