mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-01 06:40:02 -04:00
Create new notification schema
This is the schema that individual notifications will conform to when they are returned from this API. JSON logic enforces that the right keys are set depending on the `"type"`. (eg a schema with `"type": "sms"` must have a `"phone_number"` value and it cannot have an `"email_address"`)
This commit is contained in:
@@ -10,12 +10,14 @@ def validate(json_to_validate, schema):
|
||||
|
||||
@format_checker.checks('phone_number', raises=InvalidPhoneError)
|
||||
def validate_schema_phone_number(instance):
|
||||
validate_phone_number(instance)
|
||||
if instance is not None:
|
||||
validate_phone_number(instance)
|
||||
return True
|
||||
|
||||
@format_checker.checks('email_address', raises=InvalidEmailError)
|
||||
def validate_schema_email_address(instance):
|
||||
validate_email_address(instance)
|
||||
if instance is not None:
|
||||
validate_email_address(instance)
|
||||
return True
|
||||
|
||||
validator = Draft4Validator(schema, format_checker=format_checker)
|
||||
|
||||
Reference in New Issue
Block a user