"""Json schema to validate POST and PUT request.""" from timed_release import config from timed_release.constants import field_const schema = { '$schema': 'http://json-schema.org/draft-04/schema#', 'title': 'Validation schema of POST and PUT request', 'type': 'object', 'properties': { field_const.PRODUCT_ID: { 'type': 'integer', 'minimum': 1 }, field_const.TIME_OF_DAY_PRODUCT: { 'type': 'string', 'pattern': '^(([0-1]?[0-9])|(2[0-3])):[0-5][0-9]:[0-5][0-9]$' }, field_const.TIME_ZONE: { 'type': 'string', 'enum': list(config.TIME_ZONES) }, field_const.STORE_IDS: { 'type': 'array', 'uniqueItems': True, 'minItems': 1, 'items': { 'allOf': [{ 'type': 'integer', 'minimum': 1 }] } } }, 'required': [ field_const.PRODUCT_ID, field_const.TIME_ZONE, field_const.TIME_OF_DAY_PRODUCT, field_const.STORE_IDS], 'additionalProperties': False}