From f291fbf4dec94c5feb4e57e15c3f903390e1f12d Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <a.schlemmer@indiscale.com> Date: Mon, 25 Nov 2024 14:31:59 +0100 Subject: [PATCH] DOC(scanner): added docstring for validation function --- src/caoscrawler/validator.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/caoscrawler/validator.py b/src/caoscrawler/validator.py index e1d36a39..91313daf 100644 --- a/src/caoscrawler/validator.py +++ b/src/caoscrawler/validator.py @@ -100,5 +100,27 @@ def convert_record(record: db.Record): return pobj -# def validate(schema, records): -# pass + +def validate(records: list[db.Record], schema: dict) -> tuple[list, list]: + """ + Validate a list of records against a JSON schema. + + Arguments: + ---------- + + records: list[db.Record] + List of records that will be validated. + + schema: dict + A JSON schema generated using `load_json_schema_from_datamodel_yaml`. + + Returns: + -------- + A tuple containing two elements: + + - Index 0: A list of boolean values, one for each record in `records` determining whether + the validation was successful. + - Index 1: A list of ValidationErrors (in case of insuccesful validation) or None if + the validation was successful. + """ + pass -- GitLab