import json
import logging

import jsonschema
from pathlib import Path

logger = logging.getLogger(__name__)

def jsonSchemaValidationPath(data: dict, schemaPath: Path) -> bool:
    with open(schemaPath, 'r') as fp:
        schema = json.load(fp)

    return jsonSchemaValidation(data, schema)

def jsonSchemaValidation(data: dict, schema: dict) -> bool:
    validSchema = False
    try:
        jsonschema.validate(data, schema)
        validSchema = True
    except jsonschema.exceptions.ValidationError as e:
        logger.info("Exception while json schema validation: ", e)
        pass

    return validSchema