mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-05 10:13:26 -05:00
17 lines
500 B
Python
17 lines
500 B
Python
import os
|
|
|
|
from flask import json
|
|
import jsonschema
|
|
|
|
|
|
def validate(json_string, schema_filename):
|
|
schema_dir = os.path.join(os.path.dirname(__file__), 'schemas')
|
|
resolver = jsonschema.RefResolver('file://' + schema_dir + '/', None)
|
|
with open(os.path.join(schema_dir, schema_filename)) as schema:
|
|
jsonschema.validate(
|
|
json.loads(json_string),
|
|
json.load(schema),
|
|
format_checker=jsonschema.FormatChecker(),
|
|
resolver=resolver
|
|
)
|