"""Json schema to validate PUT workstation product schedule request.""" from datetime import datetime from jsonschema import FormatChecker from timed_release.constants import field_const, timed_release_ws @FormatChecker.cls_checks('utc-date-time') def is_utc_datetime_format(value): """Validate if the datetime string format is UTC.""" try: datetime.strptime(value, timed_release_ws.UTC_DATETIME_FOTMAT) return True except ValueError: return False schema = { '$schema': 'http://json-schema.org/draft-04/schema#', 'title': 'Validation schema of PUT workstation product schedule request', 'type': 'object', 'properties': { field_const.SALES_DATE_TIME: { 'type': 'string', 'format': 'utc-date-time' }, 'user_timezone': { 'type': 'string' } }, 'required': [field_const.SALES_DATE_TIME], 'additionalProperties': False }