diff --git a/docs/tests/post_v1_message-batches/validation.md b/docs/tests/post_v1_message-batches/validation.md
index a639aaa5d..b55daa774 100644
--- a/docs/tests/post_v1_message-batches/validation.md
+++ b/docs/tests/post_v1_message-batches/validation.md
@@ -33,11 +33,11 @@ Below is a table showing the required attributes and their locations as seen in
| nhsNumber | /data/attributes/messages/0/recipient/nhsNumber |
-## Scenario: An API consumer submitting a request with an invalid address postcode receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { sms: value, email: value, address: { lines: [], postcode: value } }
+A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array
-**Given** the API consumer provides an message body with an invalid postcode
+**Given** the API consumer provides a message body with a non-string array address lines
**When** the request is submitted
@@ -48,34 +48,34 @@ A valid contact detail must be structured in this format: { sms: value, email: v
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|-----------|------------------------------------------------|
-| LS1 6AECD | Used to ensure only valid postcode is accepted |
+| Value | Description |
+|---------|--------------------------------------------------------------|
+| [1,2] | Used to ensure only a string array address lines is accepted |
-## Scenario: An API consumer submitting a request with invalid address lines (too few) receives a 400 ‘Too few items’ response
+## Scenario: An API consumer submitting a request with a non-string address postcode receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } }
+A valid address postcode contact detail must be structured in this format: { address: { postcode: Value } } where Value is a string
-**Given** the API consumer provides an message body with with too few address lines
+**Given** the API consumer provides a message body with a non-string address postcode
**When** the request is submitted
-**Then** the response returns a 400 too few items error
+**Then** the response returns a 400 invalid value error
**Asserts**
-- Response returns a 400 ‘Too few items’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
| Value | Description |
|---------|-----------------------------------------------------------|
-| [ “1” ] | Used to ensure list of less than 2 values is not accepted |
+| [] | Used to ensure only a string address postcode is accepted |
## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } }
+A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: Value } }
**Given** the API consumer provides an message body with with too many address lines
@@ -93,11 +93,11 @@ A valid contact detail must be structured in this format: { address: { lines: [
| [ “1”, “2”, “3”, “4”, “5”, “6” ] | Used to ensure list of more than 5 values is not accepted |
-## Scenario: An API consumer submitting a request with an invalid email receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string email address receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { email: Value }
+A valid email contact detail must be structured in this format: { email: Value } where Value is a string
-**Given** the API consumer provides an message body with an invalid email address
+**Given** the API consumer provides a message body with a non-string email address
**When** the request is submitted
@@ -108,16 +108,16 @@ A valid contact detail must be structured in this format: { email: Value }
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|---------------------|------------------------------------------------------|
-| invalidEmailAddress | Used to ensure invalid email address is not accepted |
+| Value | Description |
+|---------|--------------------------------------------------------|
+| [] | Used to ensure only a string email address is accepted |
-## Scenario: An API consumer submitting a request with an invalid email receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string email address receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { email: Value }
+A valid email contact detail must be structured in this format: { email: Value } where Value is a string
-**Given** the API consumer provides an message body with an invalid email address
+**Given** the API consumer provides a message body with a non-string email address
**When** the request is submitted
@@ -128,16 +128,16 @@ A valid contact detail must be structured in this format: { email: Value }
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|---------------------|------------------------------------------------------|
-| invalidEmailAddress | Used to ensure invalid email address is not accepted |
+| Value | Description |
+|---------|--------------------------------------------------------|
+| [] | Used to ensure only a string email address is accepted |
-## Scenario: An API consumer submitting a request with an invalid sms receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response
-A valid sms contact detail must be structured in this format: { sms: value }
+A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string
-**Given** the API consumer provides an message body with an invalid sms
+**Given** the API consumer provides a message body with a non-string sms
**When** the request is submitted
@@ -148,16 +148,16 @@ A valid sms contact detail must be structured in this format: { sms: value }
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|--------------|-----------------------------------------------------|
-| 077009000021 | Used to ensure invalid phone number is not accepted |
+| Value | Description |
+|---------|-------------------------------------------------------|
+| [] | Used to ensure only a string phone number is accepted |
-## Scenario: An API consumer submitting a request with an invalid sms receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response
-A valid sms contact detail must be structured in this format: { sms: value }
+A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string
-**Given** the API consumer provides an message body with an invalid sms
+**Given** the API consumer provides a message body with a non-string sms
**When** the request is submitted
@@ -168,9 +168,9 @@ A valid sms contact detail must be structured in this format: { sms: value }
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|--------------|-----------------------------------------------------|
-| 077009000021 | Used to ensure invalid phone number is not accepted |
+| Value | Description |
+|---------|-------------------------------------------------------|
+| [] | Used to ensure only a string phone number is accepted |
## Scenario: An API consumer submitting a request with an contact details when not allowed receives a 400 ‘Cannot set contact details’ response
@@ -281,9 +281,9 @@ An NHS Number is a 10 digit number used to identify patients, for more informati
- Response returns the expected error message body with references to the invalid attribute
-## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response
+## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response
-A valid personalisation must be structured in this format: { parameter: value }
+A valid personalisation must be structured in this format: { parameter: Value }
**Given** the API consumer provides a message body with an invalid personalisation
@@ -293,7 +293,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts**
-- Response returns a 400 ‘Invalid value’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
| Value | Description |
@@ -364,9 +364,9 @@ Below is a table showing the required attributes and their locations as seen in
| nhsNumber | /data/attributes/messages/0/recipient/nhsNumber |
-## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response
+## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response
-A valid personalisation must be structured in this format: { parameter: value }
+A valid personalisation must be structured in this format: { parameter: Value }
**Given** the API consumer provides a message body with an invalid personalisation
@@ -376,7 +376,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts**
-- Response returns a 400 ‘Invalid value’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
| Value | Description |
diff --git a/docs/tests/post_v1_single-message/validation.md b/docs/tests/post_v1_single-message/validation.md
index f60681457..9103f6de9 100644
--- a/docs/tests/post_v1_single-message/validation.md
+++ b/docs/tests/post_v1_single-message/validation.md
@@ -1,11 +1,11 @@
# Validation Tests
-## Scenario: An API consumer submitting a request with an invalid address postcode receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { sms: value, email: value, address: { lines: [], postcode: value } }
+A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array
-**Given** the API consumer provides an message body with an invalid postcode
+**Given** the API consumer provides a message body with a non-string array address lines
**When** the request is submitted
@@ -16,34 +16,14 @@ A valid contact detail must be structured in this format: { sms: value, email: v
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|-----------|------------------------------------------------|
-| LS1 6AECD | Used to ensure only valid postcode is accepted |
-
-
-## Scenario: An API consumer submitting a request with invalid address lines (too few) receives a 400 ‘Too few items’ response
-
-A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } }
-
-**Given** the API consumer provides an message body with with too few address lines
-
-**When** the request is submitted
-
-**Then** the response returns a 400 too few items error
-
-
-**Asserts**
-- Response returns a 400 ‘Too few items’ error
-- Response returns the expected error message body with references to the invalid attribute
-
-| Value | Description |
-|---------|-----------------------------------------------------------|
-| [ “1” ] | Used to ensure list of less than 2 values is not accepted |
+| Value | Description |
+|---------|--------------------------------------------------------------|
+| [1,2] | Used to ensure only a string array address lines is accepted |
## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } }
+A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: Value } }
**Given** the API consumer provides an message body with with too many address lines
@@ -61,11 +41,11 @@ A valid contact detail must be structured in this format: { address: { lines: [
| [ “1”, “2”, “3”, “4”, “5”, “6” ] | Used to ensure list of more than 5 values is not accepted |
-## Scenario: An API consumer submitting a request with an invalid email receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string email address receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { email: Value }
+A valid email contact detail must be structured in this format: { email: Value } where Value is a string
-**Given** the API consumer provides an message body with an invalid email address
+**Given** the API consumer provides a message body with a non-string email address
**When** the request is submitted
@@ -76,16 +56,16 @@ A valid contact detail must be structured in this format: { email: Value }
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|---------------------|------------------------------------------------------|
-| invalidEmailAddress | Used to ensure invalid email address is not accepted |
+| Value | Description |
+|---------|--------------------------------------------------------|
+| [] | Used to ensure only a string email address is accepted |
-## Scenario: An API consumer submitting a request with an invalid sms receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response
-A valid sms contact detail must be structured in this format: { sms: value }
+A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string
-**Given** the API consumer provides an message body with an invalid sms
+**Given** the API consumer provides a message body with a non-string sms
**When** the request is submitted
@@ -96,9 +76,9 @@ A valid sms contact detail must be structured in this format: { sms: value }
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|--------------|-----------------------------------------------------|
-| 077009000021 | Used to ensure invalid phone number is not accepted |
+| Value | Description |
+|---------|-------------------------------------------------------|
+| [] | Used to ensure only a string phone number is accepted |
## Scenario: An API consumer submitting a request with an contact details when not allowed receives a 400 ‘Cannot set contact details’ response
@@ -192,9 +172,9 @@ An NHS Number is a 10 digit number used to identify patients, for more informati
- Response returns the expected error message body with references to the invalid attribute
-## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response
+## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response
-A valid personalisation must be structured in this format: { parameter: value }
+A valid personalisation must be structured in this format: { parameter: Value }
**Given** the API consumer provides a message body with an invalid personalisation
@@ -204,7 +184,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts**
-- Response returns a 400 ‘Invalid value’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
| Value | Description |
@@ -259,9 +239,9 @@ Below is a table showing the required attributes and their locations as seen in
| nhsNumber | /data/attributes/recipient/nhsNumber |
-## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response
+## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response
-A valid personalisation must be structured in this format: { parameter: value }
+A valid personalisation must be structured in this format: { parameter: Value }
**Given** the API consumer provides a message body with an invalid personalisation
@@ -271,7 +251,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts**
-- Response returns a 400 ‘Invalid value’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
| Value | Description |
diff --git a/docs/tests/sandbox/post_v1_message-batches/validation.md b/docs/tests/sandbox/post_v1_message-batches/validation.md
index 8dc7d17b9..cf95dd96f 100644
--- a/docs/tests/sandbox/post_v1_message-batches/validation.md
+++ b/docs/tests/sandbox/post_v1_message-batches/validation.md
@@ -129,29 +129,29 @@ Below is a table showing the required attributes and their locations as seen in
| nhsNumber | /data/attributes/messages/0/recipient/nhsNumber |
-## Scenario: An API consumer submitting a request with invalid address lines (too few) receives a 400 ‘Too few items’ response
+## Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } }
+A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array
-**Given** the API consumer provides an message body with with too few address lines
+**Given** the API consumer provides a message body with a non-string array address lines
**When** the request is submitted
-**Then** the response returns a 400 too few items error
+**Then** the response returns a 400 invalid value error
**Asserts**
-- Response returns a 400 ‘Too few items’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|---------|-----------------------------------------------------------|
-| [ “1” ] | Used to ensure list of less than 2 values is not accepted |
+| Value | Description |
+|---------|--------------------------------------------------------------|
+| [1,2] | Used to ensure only a string array address lines is accepted |
## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } }
+A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: Value } }
**Given** the API consumer provides an message body with with too many address lines
@@ -183,11 +183,11 @@ A valid contact detail must be structured in this format: { address: { lines: [
- Response returns the expected error message body
-## Scenario: An API consumer submitting a request with an invalid email receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string email address receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { email: Value }
+A valid email contact detail must be structured in this format: { email: Value } where Value is a string
-**Given** the API consumer provides an message body with an invalid email address
+**Given** the API consumer provides a message body with a non-string email address
**When** the request is submitted
@@ -198,9 +198,9 @@ A valid contact detail must be structured in this format: { email: Value }
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|---------------------|------------------------------------------------------|
-| invalidEmailAddress | Used to ensure invalid email address is not accepted |
+| Value | Description |
+|---------|--------------------------------------------------------|
+| [] | Used to ensure only a string email address is accepted |
## Scenario: An API consumer submitting a request with an invalid message batch reference receives a 400 ‘Invalid Value’ response
@@ -251,9 +251,9 @@ An NHS Number is a 10 digit number used to identify patients, for more informati
- Response returns the expected error message body with references to the invalid attribute
-## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response
+## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response
-A valid personalisation must be structured in this format: { parameter: value }
+A valid personalisation must be structured in this format: { parameter: Value }
**Given** the API consumer provides a message body with an invalid personalisation
@@ -263,7 +263,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts**
-- Response returns a 400 ‘Invalid value’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
| Value | Description |
@@ -288,11 +288,11 @@ The routing plan must be in a UUID format, for more information on UUID, look [h
- Response returns the expected error message body with references to the invalid attribute
-## Scenario: An API consumer submitting a request with an invalid sms receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response
-A valid sms contact detail must be structured in this format: { sms: value }
+A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string
-**Given** the API consumer provides an message body with an invalid sms
+**Given** the API consumer provides a message body with a non-string sms
**When** the request is submitted
@@ -303,9 +303,9 @@ A valid sms contact detail must be structured in this format: { sms: value }
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|--------------|-----------------------------------------------------|
-| 077009000021 | Used to ensure invalid phone number is not accepted |
+| Value | Description |
+|---------|-------------------------------------------------------|
+| [] | Used to ensure only a string phone number is accepted |
## Scenario: An API consumer submitting a request with an invalid message value receives a 400 ‘Invalid Value’ response
@@ -336,9 +336,9 @@ A valid sms contact detail must be structured in this format: { sms: value }
- Response returns the expected error message body with references to the invalid attribute
-## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response
+## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response
-A valid personalisation must be structured in this format: { parameter: value }
+A valid personalisation must be structured in this format: { parameter: Value }
**Given** the API consumer provides a message body with an invalid personalisation
@@ -348,7 +348,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts**
-- Response returns a 400 ‘Invalid value’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
| Value | Description |
diff --git a/docs/tests/sandbox/post_v1_messages/validation.md b/docs/tests/sandbox/post_v1_messages/validation.md
index 475d93a1f..ded2fb523 100644
--- a/docs/tests/sandbox/post_v1_messages/validation.md
+++ b/docs/tests/sandbox/post_v1_messages/validation.md
@@ -62,29 +62,29 @@ Below is a table showing the required attributes and their locations as seen in
| nhsNumber | /data/attributes/recipient/nhsNumber |
-## Scenario: An API consumer submitting a request with invalid address lines (too few) receives a 400 ‘Too few items’ response
+## Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } }
+A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array
-**Given** the API consumer provides an message body with with too few address lines
+**Given** the API consumer provides a message body with a non-string array address lines
**When** the request is submitted
-**Then** the response returns a 400 too few items error
+**Then** the response returns a 400 invalid value error
**Asserts**
-- Response returns a 400 ‘Too few items’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|---------|-----------------------------------------------------------|
-| [ “1” ] | Used to ensure list of less than 2 values is not accepted |
+| Value | Description |
+|---------|--------------------------------------------------------------|
+| [1,2] | Used to ensure only a string array address lines is accepted |
## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } }
+A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: Value } }
**Given** the API consumer provides an message body with with too many address lines
@@ -116,11 +116,11 @@ A valid contact detail must be structured in this format: { address: { lines: [
- Response returns the expected error message body
-## Scenario: An API consumer submitting a request with an invalid email receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string email address receives a 400 ‘Invalid Value’ response
-A valid contact detail must be structured in this format: { email: Value }
+A valid email contact detail must be structured in this format: { email: Value } where Value is a string
-**Given** the API consumer provides an message body with an invalid email address
+**Given** the API consumer provides a message body with a non-string email address
**When** the request is submitted
@@ -131,9 +131,9 @@ A valid contact detail must be structured in this format: { email: Value }
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|---------------------|------------------------------------------------------|
-| invalidEmailAddress | Used to ensure invalid email address is not accepted |
+| Value | Description |
+|---------|--------------------------------------------------------|
+| [] | Used to ensure only a string email address is accepted |
## Scenario: An API consumer submitting a request with an invalid message reference receives a 400 ‘Invalid Value’ response
@@ -168,9 +168,9 @@ An NHS Number is a 10 digit number used to identify patients, for more informati
- Response returns the expected error message body with references to the invalid attribute
-## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response
+## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response
-A valid personalisation must be structured in this format: { parameter: value }
+A valid personalisation must be structured in this format: { parameter: Value }
**Given** the API consumer provides a message body with an invalid personalisation
@@ -180,7 +180,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts**
-- Response returns a 400 ‘Invalid value’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
| Value | Description |
@@ -205,11 +205,11 @@ The routing plan must be in a UUID format, for more information on UUID, look [h
- Response returns the expected error message body with references to the invalid attribute
-## Scenario: An API consumer submitting a request with an invalid sms receives a 400 ‘Invalid Value’ response
+## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response
-A valid sms contact detail must be structured in this format: { sms: value }
+A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string
-**Given** the API consumer provides an message body with an invalid sms
+**Given** the API consumer provides a message body with a non-string sms
**When** the request is submitted
@@ -220,9 +220,9 @@ A valid sms contact detail must be structured in this format: { sms: value }
- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
-| Value | Description |
-|--------------|-----------------------------------------------------|
-| 077009000021 | Used to ensure invalid phone number is not accepted |
+| Value | Description |
+|---------|-------------------------------------------------------|
+| [] | Used to ensure only a string phone number is accepted |
## Scenario: An API consumer submitting a request with an contact details when not allowed receives a 400 ‘Cannot set contact details’ response
@@ -239,9 +239,9 @@ A valid sms contact detail must be structured in this format: { sms: value }
- Response returns the expected error message body with references to the invalid attribute
-## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response
+## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response
-A valid personalisation must be structured in this format: { parameter: value }
+A valid personalisation must be structured in this format: { parameter: Value }
**Given** the API consumer provides a message body with an invalid personalisation
@@ -251,7 +251,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts**
-- Response returns a 400 ‘Invalid value’ error
+- Response returns a 400 ‘Invalid Value’ error
- Response returns the expected error message body with references to the invalid attribute
| Value | Description |
diff --git a/sandbox/__test__/batch_send.spec.js b/sandbox/__test__/batch_send.spec.js
index d5a1c2941..4b9ca1c49 100644
--- a/sandbox/__test__/batch_send.spec.js
+++ b/sandbox/__test__/batch_send.spec.js
@@ -996,7 +996,7 @@ describe("/api/v1/send", () => {
recipient: {
nhsNumber: "1",
contactDetails: {
- sms: "11111111111",
+ sms: 1234,
},
},
},
@@ -1006,12 +1006,12 @@ describe("/api/v1/send", () => {
})
.expect(400, {
message:
- "Invalid recipient contact details. Field 'sms': Input failed format check",
+ "Invalid recipient contact details. Field 'sms': 'sms' is not a string",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/messages/0/recipient/contactDetails/sms",
- message: "Input failed format check",
+ message: "'sms' is not a string",
title: "Invalid value",
statusCode: 400,
},
@@ -1020,7 +1020,7 @@ describe("/api/v1/send", () => {
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when invalid value for sms alternate contact detail is provided", (done) => {
+ it("returns a 200 when email alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/send")
.set({ Authorization: "allowedContactDetailOverride" })
@@ -1036,48 +1036,7 @@ describe("/api/v1/send", () => {
recipient: {
nhsNumber: "1",
contactDetails: {
- sms: {
- hello: 1,
- },
- },
- },
- },
- ],
- },
- },
- })
- .expect(400, {
- message: "Invalid recipient contact details. Field 'sms': Input is not a string",
- errors: [
- {
- code: 'CM_INVALID_VALUE',
- field: "/data/attributes/messages/0/recipient/contactDetails/sms",
- message: "Input is not a string",
- title: "Invalid value",
- statusCode: 400,
- },
- ],
- })
- .expect("Content-Type", /json/, done);
- });
-
- it("returns a 200 when sms alternate contact detail is provided", (done) => {
- request(server)
- .post("/api/v1/send")
- .set({ Authorization: "allowedContactDetailOverride" })
- .send({
- data: {
- type: "MessageBatch",
- attributes: {
- routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1",
- messageBatchReference: "request-id",
- messages: [
- {
- messageReference: "1",
- recipient: {
- nhsNumber: "1",
- contactDetails: {
- email: "hello",
+ email: "test@test.com",
},
},
},
@@ -1105,7 +1064,7 @@ describe("/api/v1/send", () => {
recipient: {
nhsNumber: "1",
contactDetails: {
- email: "invalidEmailAddress",
+ email: 1234,
},
},
},
@@ -1115,53 +1074,12 @@ describe("/api/v1/send", () => {
})
.expect(400, {
message:
- "Invalid recipient contact details. Field 'email': Input failed format check",
+ "Invalid recipient contact details. Field 'email': 'email' is not a string",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/messages/0/recipient/contactDetails/email",
- message: "Input failed format check",
- title: "Invalid value",
- statusCode: 400,
- },
- ],
- })
- .expect("Content-Type", /json/, done);
- });
-
- it("returns a 400 when invalid value for email alternate contact detail is provided", (done) => {
- request(server)
- .post("/api/v1/send")
- .set({ Authorization: "allowedContactDetailOverride" })
- .send({
- data: {
- type: "MessageBatch",
- attributes: {
- routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1",
- messageBatchReference: "request-id",
- messages: [
- {
- messageReference: "1",
- recipient: {
- nhsNumber: "1",
- contactDetails: {
- email: {
- hello: 1,
- },
- },
- },
- },
- ],
- },
- },
- })
- .expect(400, {
- message: "Invalid recipient contact details. Field 'email': Input is not a string",
- errors: [
- {
- code: 'CM_INVALID_VALUE',
- field: "/data/attributes/messages/0/recipient/contactDetails/email",
- message: "Input is not a string",
+ message: "'email' is not a string",
title: "Invalid value",
statusCode: 400,
},
@@ -1308,13 +1226,13 @@ describe("/api/v1/send", () => {
})
.expect(400, {
message:
- "Invalid recipient contact details. Field 'address': 'lines' is missing",
+ "Invalid recipient contact details. Field 'address': 'lines' is not a string array",
errors: [
{
- code: 'CM_MISSING_VALUE',
+ code: 'CM_INVALID_VALUE',
field: "/data/attributes/messages/0/recipient/contactDetails/address",
- message: "`lines` is missing",
- title: "Missing value",
+ message: "'lines' is not a string array",
+ title: "Invalid value",
statusCode: 400,
},
],
@@ -1322,7 +1240,7 @@ describe("/api/v1/send", () => {
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when too few lines is provided in address alternate contact detail is provided", (done) => {
+ it("returns a 400 when too many lines is provided in address alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/send")
.set({ Authorization: "allowedContactDetailOverride" })
@@ -1339,7 +1257,7 @@ describe("/api/v1/send", () => {
nhsNumber: "1",
contactDetails: {
address: {
- lines: ["1"],
+ lines: ["1", "2", "3", "4", "5", "6"],
postcode: "hello",
},
},
@@ -1350,22 +1268,21 @@ describe("/api/v1/send", () => {
},
})
.expect(400, {
- message:
- "Invalid recipient contact details. Field 'address': Too few address lines were provided",
+ message: "Invalid recipient contact details. Field 'address': Too many address lines were provided",
errors: [
{
- code: 'CM_TOO_FEW_ITEMS',
+ code: 'CM_INVALID_VALUE',
field: "/data/attributes/messages/0/recipient/contactDetails/address",
- message: "Too few address lines were provided",
- title: "Too few items",
+ message: "Too many address lines were provided",
+ title: "Invalid value",
statusCode: 400,
- }
- ]
+ },
+ ],
})
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when too many lines is provided in address alternate contact detail is provided", (done) => {
+ it("returns a 400 when lines contains non-string value in address alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/send")
.set({ Authorization: "allowedContactDetailOverride" })
@@ -1382,7 +1299,7 @@ describe("/api/v1/send", () => {
nhsNumber: "1",
contactDetails: {
address: {
- lines: ["1", "2", "3", "4", "5", "6"],
+ lines: ["1", "2", 3, "4", "5"],
postcode: "hello",
},
},
@@ -1393,12 +1310,12 @@ describe("/api/v1/send", () => {
},
})
.expect(400, {
- message: "Invalid recipient contact details. Field 'address': Too many address lines were provided",
+ message: "Invalid recipient contact details. Field 'address': 'lines' is not a string array",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/messages/0/recipient/contactDetails/address",
- message: "Too many address lines were provided",
+ message: "'lines' is not a string array",
title: "Invalid value",
statusCode: 400,
},
@@ -1407,7 +1324,7 @@ describe("/api/v1/send", () => {
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when lines contains non-string value in address alternate contact detail is provided", (done) => {
+ it("returns a 200 when no postcode is provided in address alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/send")
.set({ Authorization: "allowedContactDetailOverride" })
@@ -1424,8 +1341,7 @@ describe("/api/v1/send", () => {
nhsNumber: "1",
contactDetails: {
address: {
- lines: ["1", "2", 3, "4", "5"],
- postcode: "hello",
+ lines: ["1", "2"],
},
},
},
@@ -1434,22 +1350,11 @@ describe("/api/v1/send", () => {
},
},
})
- .expect(400, {
- message: "Invalid recipient contact details. Field 'address': Lines contain non-string or empty line",
- errors: [
- {
- code: 'CM_INVALID_VALUE',
- field: "/data/attributes/messages/0/recipient/contactDetails/address",
- message: "Lines contain non-string or empty line",
- title: "Invalid value",
- statusCode: 400,
- },
- ],
- })
+ .expect(200)
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when no postcode is provided in address alternate contact detail is provided", (done) => {
+ it("returns a 200 when no lines is provided in address alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/send")
.set({ Authorization: "allowedContactDetailOverride" })
@@ -1466,7 +1371,7 @@ describe("/api/v1/send", () => {
nhsNumber: "1",
contactDetails: {
address: {
- lines: ["1", "2"],
+ postcode: "hello",
},
},
},
@@ -1475,19 +1380,7 @@ describe("/api/v1/send", () => {
},
},
})
- .expect(400, {
- message:
- "Invalid recipient contact details. Field 'address': 'postcode' is missing",
- errors: [
- {
- code: 'CM_MISSING_VALUE',
- field: "/data/attributes/messages/0/recipient/contactDetails/address",
- message: "`postcode` is missing",
- title: "Missing value",
- statusCode: 400,
- },
- ],
- })
+ .expect(200)
.expect("Content-Type", /json/, done);
});
@@ -1780,51 +1673,6 @@ describe("/api/v1/send", () => {
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when no lastName is provided in name alternate contact detail is provided", (done) => {
- request(server)
- .post("/api/v1/send")
- .set({ Authorization: "allowedContactDetailOverride" })
- .send({
- data: {
- type: "MessageBatch",
- attributes: {
- routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1",
- messageBatchReference: "request-id",
- messages: [
- {
- messageReference: "1",
- recipient: {
- nhsNumber: "1",
- contactDetails: {
- name: {
- prefix: "Mr",
- firstName: "John",
- middleNames: "Little",
- suffix: "Jr"
- },
- },
- },
- },
- ],
- },
- },
- })
- .expect(400, {
- message:
- "Invalid recipient contact details. Field 'name': 'lastName' is missing",
- errors: [
- {
- code: 'CM_MISSING_VALUE',
- field: "/data/attributes/messages/0/recipient/contactDetails/name",
- message: "`lastName` is missing",
- title: "Missing value",
- statusCode: 400,
- },
- ],
- })
- .expect("Content-Type", /json/, done);
- });
-
it("returns a 400 when lastName contains non-string value in name alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/send")
@@ -1856,12 +1704,12 @@ describe("/api/v1/send", () => {
},
})
.expect(400, {
- message: "Invalid recipient contact details. Field 'name': 'lastName' must be a non-empty string",
+ message: "Invalid recipient contact details. Field 'name': 'lastName' is not a string",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/messages/0/recipient/contactDetails/name",
- message: "'lastName' must be a non-empty string",
+ message: "'lastName' is not a string",
title: "Invalid value",
statusCode: 400,
},
@@ -1932,10 +1780,10 @@ describe("/api/v1/send", () => {
nhsNumber: "1",
contactDetails: {
address: {
- lines: ["1"],
+ lines: ["1", "2", "3", "4", "5", "6"],
postcode: [],
},
- email: "invalidEmailAddress",
+ email: 1234,
},
},
},
@@ -1945,20 +1793,20 @@ describe("/api/v1/send", () => {
})
.expect(400, {
message:
- "Invalid recipient contact details. Field 'email': Input failed format check. Field 'address': Too few address lines were provided",
+ "Invalid recipient contact details. Field 'email': 'email' is not a string. Field 'address': Too many address lines were provided",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/messages/0/recipient/contactDetails/email",
- message: "Input failed format check",
+ message: "'email' is not a string",
title: "Invalid value",
statusCode: 400,
},
{
- code: 'CM_TOO_FEW_ITEMS',
+ code: 'CM_INVALID_VALUE',
field: "/data/attributes/messages/0/recipient/contactDetails/address",
- message: "Too few address lines were provided",
- title: "Too few items",
+ message: "Too many address lines were provided",
+ title: "Invalid value",
statusCode: 400,
},
],
diff --git a/sandbox/__test__/messages.spec.js b/sandbox/__test__/messages.spec.js
index d47d18d0e..ac943f583 100644
--- a/sandbox/__test__/messages.spec.js
+++ b/sandbox/__test__/messages.spec.js
@@ -681,42 +681,6 @@ describe("/api/v1/messages", () => {
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when invalid sms alternate contact detail is provided", (done) => {
- request(server)
- .post("/api/v1/messages")
- .set({ Authorization: "allowedContactDetailOverride" })
- .send({
- data: {
- type: "Message",
- attributes: {
- routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1",
- messageReference: "b5bb84b9-a522-41e9-aa8b-ad1b6a454243",
- recipient: {
- nhsNumber: "1",
- contactDetails: {
- sms: "11111111111",
- },
- },
- personalisation: {},
- },
- },
- })
- .expect(400, {
- message:
- "Invalid recipient contact details. Field 'sms': Input failed format check",
- errors: [
- {
- code: 'CM_INVALID_VALUE',
- field: "/data/attributes/recipient/contactDetails/sms",
- message: "Input failed format check",
- title: "Invalid value",
- statusCode: 400,
- },
- ],
- })
- .expect("Content-Type", /json/, done);
- });
-
it("returns a 400 when invalid value for sms alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/messages")
@@ -740,12 +704,12 @@ describe("/api/v1/messages", () => {
},
})
.expect(400, {
- message: "Invalid recipient contact details. Field 'sms': Input is not a string",
+ message: "Invalid recipient contact details. Field 'sms': 'sms' is not a string",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/recipient/contactDetails/sms",
- message: "Input is not a string",
+ message: "'sms' is not a string",
title: "Invalid value",
statusCode: 400,
},
@@ -778,42 +742,6 @@ describe("/api/v1/messages", () => {
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when invalid email alternate contact detail is provided", (done) => {
- request(server)
- .post("/api/v1/messages")
- .set({ Authorization: "allowedContactDetailOverride" })
- .send({
- data: {
- type: "Message",
- attributes: {
- routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1",
- messageReference: "b5bb84b9-a522-41e9-aa8b-ad1b6a454243",
- recipient: {
- nhsNumber: "1",
- contactDetails: {
- email: "invalidEmailAddress",
- },
- },
- personalisation: {},
- },
- },
- })
- .expect(400, {
- message:
- "Invalid recipient contact details. Field 'email': Input failed format check",
- errors: [
- {
- code: 'CM_INVALID_VALUE',
- field: "/data/attributes/recipient/contactDetails/email",
- message: "Input failed format check",
- title: "Invalid value",
- statusCode: 400,
- },
- ],
- })
- .expect("Content-Type", /json/, done);
- });
-
it("returns a 400 when invalid value for email alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/messages")
@@ -837,12 +765,12 @@ describe("/api/v1/messages", () => {
},
})
.expect(400, {
- message: "Invalid recipient contact details. Field 'email': Input is not a string",
+ message: "Invalid recipient contact details. Field 'email': 'email' is not a string",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/recipient/contactDetails/email",
- message: "Input is not a string",
+ message: "'email' is not a string",
title: "Invalid value",
statusCode: 400,
},
@@ -973,13 +901,13 @@ describe("/api/v1/messages", () => {
})
.expect(400, {
message:
- "Invalid recipient contact details. Field 'address': 'lines' is missing",
+ "Invalid recipient contact details. Field 'address': 'lines' is not a string array",
errors: [
{
- code: 'CM_MISSING_VALUE',
+ code: 'CM_INVALID_VALUE',
field: "/data/attributes/recipient/contactDetails/address",
- message: "`lines` is missing",
- title: "Missing value",
+ message: "'lines' is not a string array",
+ title: "Invalid value",
statusCode: 400,
},
],
@@ -987,7 +915,7 @@ describe("/api/v1/messages", () => {
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when too few lines is provided in address alternate contact detail is provided", (done) => {
+ it("returns a 400 when too many lines is provided in address alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/messages")
.set({ Authorization: "allowedContactDetailOverride" })
@@ -1001,7 +929,7 @@ describe("/api/v1/messages", () => {
nhsNumber: "1",
contactDetails: {
address: {
- lines: ["1"],
+ lines: ["1", "2", "3", "4", "5", "6"],
postcode: "hello",
},
},
@@ -1011,22 +939,21 @@ describe("/api/v1/messages", () => {
},
})
.expect(400, {
- message:
- "Invalid recipient contact details. Field 'address': Too few address lines were provided",
+ message: "Invalid recipient contact details. Field 'address': Too many address lines were provided",
errors: [
{
- code: 'CM_TOO_FEW_ITEMS',
+ code: 'CM_INVALID_VALUE',
field: "/data/attributes/recipient/contactDetails/address",
- message: "Too few address lines were provided",
- title: "Too few items",
+ message: "Too many address lines were provided",
+ title: "Invalid value",
statusCode: 400,
- }
- ]
+ },
+ ],
})
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when too many lines is provided in address alternate contact detail is provided", (done) => {
+ it("returns a 400 when lines contains non-string value in address alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/messages")
.set({ Authorization: "allowedContactDetailOverride" })
@@ -1040,7 +967,7 @@ describe("/api/v1/messages", () => {
nhsNumber: "1",
contactDetails: {
address: {
- lines: ["1", "2", "3", "4", "5", "6"],
+ lines: ["1", "2", 3, "4", "5"],
postcode: "hello",
},
},
@@ -1050,12 +977,12 @@ describe("/api/v1/messages", () => {
},
})
.expect(400, {
- message: "Invalid recipient contact details. Field 'address': Too many address lines were provided",
+ message: "Invalid recipient contact details. Field 'address': 'lines' is not a string array",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/recipient/contactDetails/address",
- message: "Too many address lines were provided",
+ message: "'lines' is not a string array",
title: "Invalid value",
statusCode: 400,
},
@@ -1064,7 +991,7 @@ describe("/api/v1/messages", () => {
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when lines contains non-string value in address alternate contact detail is provided", (done) => {
+ it("returns a 201 when no postcode is provided in address alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/messages")
.set({ Authorization: "allowedContactDetailOverride" })
@@ -1078,8 +1005,7 @@ describe("/api/v1/messages", () => {
nhsNumber: "1",
contactDetails: {
address: {
- lines: ["1", "2", 3, "4", "5"],
- postcode: "hello",
+ lines: ["1", "2"],
},
},
},
@@ -1087,22 +1013,11 @@ describe("/api/v1/messages", () => {
},
},
})
- .expect(400, {
- message: "Invalid recipient contact details. Field 'address': Lines contain non-string or empty line",
- errors: [
- {
- code: 'CM_INVALID_VALUE',
- field: "/data/attributes/recipient/contactDetails/address",
- message: "Lines contain non-string or empty line",
- title: "Invalid value",
- statusCode: 400,
- },
- ],
- })
+ .expect(201)
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when no postcode is provided in address alternate contact detail is provided", (done) => {
+ it("returns a 201 when no lines is provided in address alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/messages")
.set({ Authorization: "allowedContactDetailOverride" })
@@ -1116,7 +1031,7 @@ describe("/api/v1/messages", () => {
nhsNumber: "1",
contactDetails: {
address: {
- lines: ["1", "2"],
+ postcode: "hello",
},
},
},
@@ -1124,19 +1039,7 @@ describe("/api/v1/messages", () => {
},
},
})
- .expect(400, {
- message:
- "Invalid recipient contact details. Field 'address': 'postcode' is missing",
- errors: [
- {
- code: 'CM_MISSING_VALUE',
- field: "/data/attributes/recipient/contactDetails/address",
- message: "`postcode` is missing",
- title: "Missing value",
- statusCode: 400,
- },
- ],
- })
+ .expect(201)
.expect("Content-Type", /json/, done);
});
@@ -1208,32 +1111,6 @@ describe("/api/v1/messages", () => {
.expect("Content-Type", /json/, done);
});
- it("returns a 201 when only lastName is provided for name alternate contact details", (done) => {
- request(server)
- .post("/api/v1/messages")
- .set({ Authorization: "allowedContactDetailOverride" })
- .send({
- data: {
- type: "Message",
- attributes: {
- routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1",
- messageReference: "b5bb84b9-a522-41e9-aa8b-ad1b6a454243",
- recipient: {
- nhsNumber: "1",
- contactDetails: {
- name: {
- lastName: "Smith"
- },
- },
- },
- personalisation: {},
- },
- },
- })
- .expect(201)
- .expect("Content-Type", /json/, done);
- });
-
it("returns a 400 when string for name alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/messages")
@@ -1427,47 +1304,6 @@ describe("/api/v1/messages", () => {
.expect("Content-Type", /json/, done);
});
- it("returns a 400 when no lastName is provided in name alternate contact detail is provided", (done) => {
- request(server)
- .post("/api/v1/messages")
- .set({ Authorization: "allowedContactDetailOverride" })
- .send({
- data: {
- type: "Message",
- attributes: {
- routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1",
- messageReference: "b5bb84b9-a522-41e9-aa8b-ad1b6a454243",
- recipient: {
- nhsNumber: "1",
- contactDetails: {
- name: {
- prefix: "Mr",
- firstName: "John",
- middleNames: "Little",
- suffix: "Jr"
- },
- },
- },
- personalisation: {},
- },
- },
- })
- .expect(400, {
- message:
- "Invalid recipient contact details. Field 'name': 'lastName' is missing",
- errors: [
- {
- code: 'CM_MISSING_VALUE',
- field: "/data/attributes/recipient/contactDetails/name",
- message: "`lastName` is missing",
- title: "Missing value",
- statusCode: 400,
- },
- ],
- })
- .expect("Content-Type", /json/, done);
- });
-
it("returns a 400 when lastName contains non-string value in name alternate contact detail is provided", (done) => {
request(server)
.post("/api/v1/messages")
@@ -1495,12 +1331,12 @@ describe("/api/v1/messages", () => {
},
})
.expect(400, {
- message: "Invalid recipient contact details. Field 'name': 'lastName' must be a non-empty string",
+ message: "Invalid recipient contact details. Field 'name': 'lastName' is not a string",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/recipient/contactDetails/name",
- message: "'lastName' must be a non-empty string",
+ message: "'lastName' is not a string",
title: "Invalid value",
statusCode: 400,
},
@@ -1526,7 +1362,7 @@ describe("/api/v1/messages", () => {
prefix: "Mr",
firstName: "John",
middleNames: "Little",
- lastName: "",
+ lastName: 1234,
suffix: "Jr"
},
},
@@ -1536,12 +1372,12 @@ describe("/api/v1/messages", () => {
},
})
.expect(400, {
- message: "Invalid recipient contact details. Field 'name': 'lastName' must be a non-empty string",
+ message: "Invalid recipient contact details. Field 'name': 'lastName' is not a string",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/recipient/contactDetails/name",
- message: "'lastName' must be a non-empty string",
+ message: "'lastName' is not a string",
title: "Invalid value",
statusCode: 400,
},
@@ -1605,10 +1441,10 @@ describe("/api/v1/messages", () => {
nhsNumber: "1",
contactDetails: {
address: {
- lines: ["1"],
+ lines: ["1", "2", "3", "4", "5", "6"],
postcode: [],
},
- email: "invalidEmailAddress",
+ email: 1234,
},
},
personalisation: {},
@@ -1617,20 +1453,20 @@ describe("/api/v1/messages", () => {
})
.expect(400, {
message:
- "Invalid recipient contact details. Field 'email': Input failed format check. Field 'address': Too few address lines were provided",
+ "Invalid recipient contact details. Field 'email': 'email' is not a string. Field 'address': Too many address lines were provided",
errors: [
{
code: 'CM_INVALID_VALUE',
field: "/data/attributes/recipient/contactDetails/email",
- message: "Input failed format check",
+ message: "'email' is not a string",
title: "Invalid value",
statusCode: 400,
},
{
- code: 'CM_TOO_FEW_ITEMS',
+ code: 'CM_INVALID_VALUE',
field: "/data/attributes/recipient/contactDetails/address",
- message: "Too few address lines were provided",
- title: "Too few items",
+ message: "Too many address lines were provided",
+ title: "Invalid value",
statusCode: 400,
},
],
diff --git a/sandbox/handlers/config.js b/sandbox/handlers/config.js
index cb3e2f3e5..c30d12cc5 100644
--- a/sandbox/handlers/config.js
+++ b/sandbox/handlers/config.js
@@ -25,8 +25,6 @@ const validSendingGroupIds = {
[globalFreeTextSmsSendingGroupId]: "xoERWoahq12cq8WMXya4yed9hZtZbMxJ"
};
-const invalidEmailAddress = "invalidEmailAddress";
-
const duplicateTemplates = [
{
name: "EMAIL_TEMPLATE",
@@ -68,6 +66,5 @@ export {
globalFreeTextSmsSendingGroupId,
noDefaultOdsClientAuth,
noOdsChangeClientAuth,
- notAllowedContactDetailOverride,
- invalidEmailAddress
+ notAllowedContactDetailOverride
}
diff --git a/sandbox/handlers/error_scenarios/override_contact_details.js b/sandbox/handlers/error_scenarios/override_contact_details.js
index b9189dc5c..c9cd9f5f5 100644
--- a/sandbox/handlers/error_scenarios/override_contact_details.js
+++ b/sandbox/handlers/error_scenarios/override_contact_details.js
@@ -1,8 +1,5 @@
import { notAllowedContactDetailOverride } from "../config.js";
-const invalidPhoneNumber = "11111111111";
-const invalidEmailAddress = "invalidEmailAddress";
-
function validationSuccess() {
return {
valid: true,
@@ -20,28 +17,16 @@ function smsValidation(sms, path) {
if (!sms) {
return validationSuccess();
}
- if (sms === invalidPhoneNumber) {
- return validationFailure([
- {
- title: "Invalid value",
- code: 'CM_INVALID_VALUE',
- field: `${path}/recipient/contactDetails/sms`,
- message: "Input failed format check",
- statusCode: 400,
- },
- `Field 'sms': Input failed format check`,
- ]);
- }
if (typeof sms !== "string") {
return validationFailure([
{
title: "Invalid value",
code: 'CM_INVALID_VALUE',
field: `${path}/recipient/contactDetails/sms`,
- message: "Input is not a string",
+ message: "'sms' is not a string",
statusCode: 400,
},
- `Field 'sms': Input is not a string`,
+ `Field 'sms': 'sms' is not a string`,
]);
}
return validationSuccess();
@@ -51,28 +36,16 @@ function emailValidation(email, path) {
if (!email) {
return validationSuccess();
}
- if (email === invalidEmailAddress) {
- return validationFailure([
- {
- title: "Invalid value",
- code: 'CM_INVALID_VALUE',
- field: `${path}/recipient/contactDetails/email`,
- message: "Input failed format check",
- statusCode: 400,
- },
- `Field 'email': Input failed format check`,
- ]);
- }
if (typeof email !== "string") {
return validationFailure([
{
title: "Invalid value",
code: 'CM_INVALID_VALUE',
field: `${path}/recipient/contactDetails/email`,
- message: "Input is not a string",
+ message: "'email' is not a string",
statusCode: 400,
},
- `Field 'email': Input is not a string`,
+ `Field 'email': 'email' is not a string`,
]);
}
return validationSuccess();
@@ -96,83 +69,48 @@ function addressValidation(address, path) {
]);
}
- if (!address.lines) {
- return validationFailure([
- {
- title: "Missing value",
- code: 'CM_MISSING_VALUE',
- field: `${path}/recipient/contactDetails/address`,
- message: "`lines` is missing",
- statusCode: 400,
- },
- `Field 'address': 'lines' is missing`,
- ]);
- }
- if (!Array.isArray(address.lines)) {
- return validationFailure([
- {
- title: "Missing value",
- code: 'CM_MISSING_VALUE',
- field: `${path}/recipient/contactDetails/address`,
- message: "`lines` is missing",
- statusCode: 400,
- },
- `Field 'address': 'lines' is missing`,
- ]);
- }
-
- if (address.lines.some((line) => typeof line !== "string")) {
- return validationFailure([
- {
- title: "Invalid value",
- code: 'CM_INVALID_VALUE',
- field: `${path}/recipient/contactDetails/address`,
- message: "Lines contain non-string or empty line",
- statusCode: 400,
- },
- `Field 'address': Lines contain non-string or empty line`,
- ]);
- }
+ if ("lines" in address) {
+ if (!Array.isArray(address.lines)) {
+ return validationFailure([
+ {
+ title: "Invalid value",
+ code: 'CM_INVALID_VALUE',
+ field: `${path}/recipient/contactDetails/address`,
+ message: "'lines' is not a string array",
+ statusCode: 400,
+ },
+ `Field 'address': 'lines' is not a string array`,
+ ]);
+ }
- if (address.lines.length < 2) {
- return validationFailure([
- {
- code: 'CM_TOO_FEW_ITEMS',
- title: "Too few items",
- field: `${path}/recipient/contactDetails/address`,
- message: "Too few address lines were provided",
- statusCode: 400,
- },
- `Field 'address': Too few address lines were provided`,
- ]);
- }
- if (address.lines.length > 5) {
- return validationFailure([
- {
- title: "Invalid value",
- code: 'CM_INVALID_VALUE',
- field: `${path}/recipient/contactDetails/address`,
- message: "Too many address lines were provided",
- statusCode: 400,
- },
- `Field 'address': Too many address lines were provided`,
- ]);
- }
+ if (address.lines.some((line) => typeof line !== "string")) {
+ return validationFailure([
+ {
+ title: "Invalid value",
+ code: 'CM_INVALID_VALUE',
+ field: `${path}/recipient/contactDetails/address`,
+ message: "'lines' is not a string array",
+ statusCode: 400,
+ },
+ `Field 'address': 'lines' is not a string array`,
+ ]);
+ }
- if (!address.postcode) {
- return validationFailure([
- {
- title: "Missing value",
- code: 'CM_MISSING_VALUE',
- field: `${path}/recipient/contactDetails/address`,
- message: "`postcode` is missing",
- statusCode: 400,
- },
- `Field 'address': 'postcode' is missing`,
- ]);
+ if (address.lines.length > 5) {
+ return validationFailure([
+ {
+ title: "Invalid value",
+ code: 'CM_INVALID_VALUE',
+ field: `${path}/recipient/contactDetails/address`,
+ message: "Too many address lines were provided",
+ statusCode: 400,
+ },
+ `Field 'address': Too many address lines were provided`,
+ ]);
+ }
}
- if (typeof address.postcode !== "string") {
+ if ("postcode" in address && typeof address.postcode !== "string") {
return validationFailure([
{
title: "Invalid value",
@@ -188,7 +126,6 @@ function addressValidation(address, path) {
}
function nameValidation(name, path) {
-
if (!name) {
return validationSuccess();
}
@@ -245,29 +182,16 @@ function nameValidation(name, path) {
]);
}
- if (typeof name.lastName === "undefined") {
- return validationFailure([
- {
- title: "Missing value",
- code: 'CM_MISSING_VALUE',
- field: `${path}/recipient/contactDetails/name`,
- message: "`lastName` is missing",
- statusCode: 400,
- },
- `Field 'name': 'lastName' is missing`,
- ]);
- }
-
- if (typeof name.lastName !== "string" || name.lastName.trim() === "") {
+ if ("lastName" in name && typeof name.lastName !== "string") {
return validationFailure([
{
title: "Invalid value",
code: 'CM_INVALID_VALUE',
field: `${path}/recipient/contactDetails/name`,
- message: "'lastName' must be a non-empty string",
+ message: "'lastName' is not a string",
statusCode: 400,
},
- `Field 'name': 'lastName' must be a non-empty string`,
+ `Field 'name': 'lastName' is not a string`,
]);
}
diff --git a/specification/responses/4xx/message_batches/400_UnableToProcessMessageBatch.yaml b/specification/responses/4xx/message_batches/400_UnableToProcessMessageBatch.yaml
index 45553bb2b..6b3f02829 100644
--- a/specification/responses/4xx/message_batches/400_UnableToProcessMessageBatch.yaml
+++ b/specification/responses/4xx/message_batches/400_UnableToProcessMessageBatch.yaml
@@ -44,13 +44,6 @@ description: |+
-d '{"data":{"type":"MessageBatch","attributes":{"routingPlanId":"b838b13c-f98c-4def-93f0-515d4e4f4ee1","messageBatchReference":"346e3fc3-0b55-4c0d-bec9-0cc5aa431836","messages":[{"messageReference":"da0b1495-c7cb-468c-9d81-07dee089d728","recipient":{"nhsNumber":"9990548609","contactDetails":{"sms":"07777000000"}},"personalisation":{}}]}}}' \
https://sandbox.api.service.nhs.uk/comms/v1/message-batches
```
-
- Contact detail validation errors can be triggered with the following values.
-
- | Field | Value | Description |
- | ---------- | ----- | ----------- |
- | sms | 11111111111 | Returns 'Input failed format check' error with a pointer to sms. |
- | email | invalidEmailAddress | Returns 'Input failed format check' error with a pointer to email. |
content:
application/vnd.api+json:
schema:
diff --git a/specification/responses/4xx/messages/400_UnableToProcessMessage.yaml b/specification/responses/4xx/messages/400_UnableToProcessMessage.yaml
index 65d2dd229..a2562cc3f 100644
--- a/specification/responses/4xx/messages/400_UnableToProcessMessage.yaml
+++ b/specification/responses/4xx/messages/400_UnableToProcessMessage.yaml
@@ -42,13 +42,6 @@ description: |+
-d '{"data": {"type": "Message","attributes": {"routingPlanId": "b838b13c-f98c-4def-93f0-515d4e4f4ee1","messageReference": "da0b1495-c7cb-468c-9d81-07dee089d728","recipient": {"nhsNumber": "9990548609","contactDetails": {"sms": "07777000000"}},"personalisation": {}}}}' \
https://sandbox.api.service.nhs.uk/comms/v1/messages
```
-
- Contact detail validation errors can be triggered with the following values.
-
- | Field | Value | Description |
- | ---------- | ----- | ----------- |
- | sms | 11111111111 | Returns 'Input failed format check' error with a pointer to sms. |
- | email | invalidEmailAddress | Returns 'Input failed format check' error with a pointer to email. |
content:
application/vnd.api+json:
schema:
diff --git a/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py b/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py
index d7d1e2811..2b8b8d0f3 100644
--- a/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py
+++ b/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py
@@ -18,7 +18,7 @@ def test_invalid_sms_contact_details(url, bearer_token):
data = Generators.generate_valid_create_message_batch_body("dev")
data["data"]["attributes"]["messages"][0]["recipient"] = {
"contactDetails": {
- "sms": "077009000021"
+ "sms": 1234
}
}
@@ -33,7 +33,7 @@ def test_invalid_sms_contact_details(url, bearer_token):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/0/recipient/contactDetails/sms",
- "Input failed format check"
+ "'sms' is not a string"
),
None
)
@@ -51,7 +51,7 @@ def test_invalid_sms_contact_details_second_message(url, bearer_token):
data = Generators.generate_valid_create_message_batch_body("dev")
data["data"]["attributes"]["messages"][1]["recipient"] = {
"contactDetails": {
- "sms": "077009000021"
+ "sms": 1234
}
}
@@ -66,7 +66,7 @@ def test_invalid_sms_contact_details_second_message(url, bearer_token):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/1/recipient/contactDetails/sms",
- "Input failed format check"
+ "'sms' is not a string"
),
None
)
@@ -84,7 +84,7 @@ def test_invalid_email_contact_details(url, bearer_token):
data = Generators.generate_valid_create_message_batch_body("dev")
data["data"]["attributes"]["messages"][0]["recipient"] = {
"contactDetails": {
- "email": "invalidEmailAddress"
+ "email": 1234
}
}
@@ -99,7 +99,7 @@ def test_invalid_email_contact_details(url, bearer_token):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/0/recipient/contactDetails/email",
- "Input failed format check"
+ "'email' is not a string"
),
None
)
@@ -117,7 +117,7 @@ def test_invalid_email_contact_details_third_message(url, bearer_token):
data = Generators.generate_valid_create_message_batch_body("dev")
data["data"]["attributes"]["messages"][2]["recipient"] = {
"contactDetails": {
- "email": "invalidEmailAddress"
+ "email": 1234
}
}
@@ -131,7 +131,7 @@ def test_invalid_email_contact_details_third_message(url, bearer_token):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/2/recipient/contactDetails/email",
- "Input failed format check"
+ "'email' is not a string"
),
None
)
@@ -141,15 +141,15 @@ def test_invalid_email_contact_details_third_message(url, bearer_token):
@pytest.mark.devtest
@pytest.mark.inttest
@pytest.mark.prodtest
-def test_invalid_address_contact_details_too_few_lines(url, bearer_token):
+def test_invalid_address_contact_details_too_many_lines(url, bearer_token):
"""
- .. include:: ../partials/validation/test_invalid_contact_details_address_lines_too_few.rst
+ .. include:: ../partials/validation/test_invalid_contact_details_address_lines_too_many.rst
"""
headers = Generators.generate_valid_headers(bearer_token.value)
data = Generators.generate_valid_create_message_batch_body("dev")
data["data"]["attributes"]["messages"][0]["recipient"]["contactDetails"] = {
"address": {
- "lines": ["1"],
+ "lines": ["1", "2", "3", "4", "5", "6"],
"postcode": "LS1 6AE"
}
}
@@ -163,9 +163,9 @@ def test_invalid_address_contact_details_too_few_lines(url, bearer_token):
Assertions.assert_error_with_optional_correlation_id(
resp,
400,
- Generators.generate_too_few_items_error_custom_detail(
+ Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/0/recipient/contactDetails/address",
- "Too few address lines were provided"
+ "Too many address lines were provided"
),
None
)
@@ -175,15 +175,15 @@ def test_invalid_address_contact_details_too_few_lines(url, bearer_token):
@pytest.mark.devtest
@pytest.mark.inttest
@pytest.mark.prodtest
-def test_invalid_address_contact_details_too_many_lines(url, bearer_token):
+def test_invalid_address_contact_details_lines_not_string_array(url, bearer_token):
"""
- .. include:: ../partials/validation/test_invalid_contact_details_address_lines_too_many.rst
+ .. include:: ../partials/validation/test_invalid_contact_details_address_lines.rst
"""
headers = Generators.generate_valid_headers(bearer_token.value)
data = Generators.generate_valid_create_message_batch_body("dev")
data["data"]["attributes"]["messages"][0]["recipient"]["contactDetails"] = {
"address": {
- "lines": ["1", "2", "3", "4", "5", "6"],
+ "lines": [1, 2, 3],
"postcode": "LS1 6AE"
}
}
@@ -199,7 +199,7 @@ def test_invalid_address_contact_details_too_many_lines(url, bearer_token):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/0/recipient/contactDetails/address",
- "Too many address lines were provided"
+ "'lines' is not a string array"
),
None
)
@@ -209,7 +209,7 @@ def test_invalid_address_contact_details_too_many_lines(url, bearer_token):
@pytest.mark.devtest
@pytest.mark.inttest
@pytest.mark.prodtest
-def test_invalid_address_contact_details_postcode(url, bearer_token):
+def test_invalid_address_contact_details_postcode_not_string(url, bearer_token):
"""
.. include:: ../partials/validation/test_invalid_contact_details_address_postcode.rst
"""
@@ -217,8 +217,8 @@ def test_invalid_address_contact_details_postcode(url, bearer_token):
data = Generators.generate_valid_create_message_batch_body("dev")
data["data"]["attributes"]["messages"][0]["recipient"]["contactDetails"] = {
"address": {
- "lines": ["1", "2", "3", "4", "5"],
- "postcode": "LS1 6AECD"
+ "lines": ["1", "2"],
+ "postcode": []
}
}
@@ -233,7 +233,7 @@ def test_invalid_address_contact_details_postcode(url, bearer_token):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/0/recipient/contactDetails/address",
- "Postcode input failed format check"
+ "'postcode' is not a string"
),
None
)
diff --git a/tests/api/single_message/field_validation/test_400_invalid_contact_details.py b/tests/api/single_message/field_validation/test_400_invalid_contact_details.py
index a9214d0e9..08b92fbe1 100644
--- a/tests/api/single_message/field_validation/test_400_invalid_contact_details.py
+++ b/tests/api/single_message/field_validation/test_400_invalid_contact_details.py
@@ -16,7 +16,7 @@ def test_invalid_sms_contact_details(url, bearer_token):
"""
headers = Generators.generate_valid_headers(bearer_token.value)
data = Generators.generate_valid_create_message_body("dev")
- data["data"]["attributes"]["recipient"]["contactDetails"] = {"sms": "11111111111"}
+ data["data"]["attributes"]["recipient"]["contactDetails"] = {"sms": 1234}
resp = requests.post(
f"{url}{MESSAGES_ENDPOINT}",
@@ -29,7 +29,7 @@ def test_invalid_sms_contact_details(url, bearer_token):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/recipient/contactDetails/sms",
- "Input failed format check"
+ "'sms' is not a string"
),
None
)
@@ -45,7 +45,7 @@ def test_invalid_email_contact_details(url, bearer_token):
"""
headers = Generators.generate_valid_headers(bearer_token.value)
data = Generators.generate_valid_create_message_body("dev")
- data["data"]["attributes"]["recipient"]["contactDetails"] = {"email": "invalidEmailAddress"}
+ data["data"]["attributes"]["recipient"]["contactDetails"] = {"email": 1234}
resp = requests.post(
f"{url}{MESSAGES_ENDPOINT}",
@@ -58,41 +58,7 @@ def test_invalid_email_contact_details(url, bearer_token):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/recipient/contactDetails/email",
- "Input failed format check"
- ),
- None
- )
-
-
-@pytest.mark.test
-@pytest.mark.devtest
-@pytest.mark.inttest
-@pytest.mark.prodtest
-def test_invalid_address_contact_details_too_few_lines(url, bearer_token):
- """
- .. include :: /partials/validation/test_invalid_contact_details_address_lines_too_few.rst
- """
- headers = Generators.generate_valid_headers(bearer_token.value)
- data = Generators.generate_valid_create_message_body("dev")
- data["data"]["attributes"]["recipient"]["contactDetails"] = {
- "address": {
- "lines": ["1"],
- "postcode": "test"
- }
- }
-
- resp = requests.post(
- f"{url}{MESSAGES_ENDPOINT}",
- headers=headers,
- json=data
- )
-
- Assertions.assert_error_with_optional_correlation_id(
- resp,
- 400,
- Generators.generate_too_few_items_error_custom_detail(
- "/data/attributes/recipient/contactDetails/address",
- "Too few address lines were provided"
+ "'email' is not a string"
),
None
)
@@ -136,16 +102,16 @@ def test_invalid_address_contact_details_too_many_lines(url, bearer_token):
@pytest.mark.devtest
@pytest.mark.inttest
@pytest.mark.prodtest
-def test_invalid_address_contact_details_postcode(url, bearer_token):
+def test_invalid_address_contact_details_lines_not_string_array(url, bearer_token):
"""
- .. include :: /partials/validation/test_invalid_contact_details_address_postcode.rst
+ .. include:: /partials/validation/test_invalid_contact_details_address_lines.rst
"""
headers = Generators.generate_valid_headers(bearer_token.value)
data = Generators.generate_valid_create_message_body("dev")
data["data"]["attributes"]["recipient"]["contactDetails"] = {
"address": {
- "lines": ["1", "2", "3", "4", "5"],
- "postcode": "LS1 6AECD"
+ "lines": [1, 2, 3],
+ "postcode": "test"
}
}
@@ -160,7 +126,7 @@ def test_invalid_address_contact_details_postcode(url, bearer_token):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/recipient/contactDetails/address",
- "Postcode input failed format check"
+ "'lines' is not a string array"
),
None
)
diff --git a/tests/docs/partials/validation/test_invalid_contact_details_address_lines.rst b/tests/docs/partials/validation/test_invalid_contact_details_address_lines.rst
new file mode 100644
index 000000000..e7a166652
--- /dev/null
+++ b/tests/docs/partials/validation/test_invalid_contact_details_address_lines.rst
@@ -0,0 +1,22 @@
+Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 'Invalid Value' response
+============================================================================================================================
+
+A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array
+
+| **Given** the API consumer provides a message body with a non-string array address lines
+| **When** the request is submitted
+| **Then** the response returns a 400 invalid value error
+
+**Asserts**
+- Response returns a 400 'Invalid Value' error
+- Response returns the expected error message body with references to the invalid attribute
+
+.. list-table::
+ :widths: 50 50
+ :header-rows: 1
+
+ * - Value
+ - Description
+ * - [1,2]
+ - Used to ensure only a string array address lines is accepted
+
diff --git a/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_few.rst b/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_few.rst
deleted file mode 100644
index 61132ebd1..000000000
--- a/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_few.rst
+++ /dev/null
@@ -1,22 +0,0 @@
-Scenario: An API consumer submitting a request with invalid address lines (too few) receives a 400 'Too few items' response
-============================================================================================================================
-
-A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } }
-
-| **Given** the API consumer provides an message body with with too few address lines
-| **When** the request is submitted
-| **Then** the response returns a 400 too few items error
-
-**Asserts**
-- Response returns a 400 'Too few items' error
-- Response returns the expected error message body with references to the invalid attribute
-
-.. list-table::
- :widths: 50 50
- :header-rows: 1
-
- * - Value
- - Description
- * - [ "1" ]
- - Used to ensure list of less than 2 values is not accepted
-
diff --git a/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_many.rst b/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_many.rst
index 3727100ce..126ec7407 100644
--- a/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_many.rst
+++ b/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_many.rst
@@ -1,7 +1,7 @@
Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 'Invalid Value' response
===============================================================================================================================
-A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } }
+A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: Value } }
| **Given** the API consumer provides an message body with with too many address lines
| **When** the request is submitted
diff --git a/tests/docs/partials/validation/test_invalid_contact_details_address_postcode.rst b/tests/docs/partials/validation/test_invalid_contact_details_address_postcode.rst
index 051f1b19e..1c05951f0 100644
--- a/tests/docs/partials/validation/test_invalid_contact_details_address_postcode.rst
+++ b/tests/docs/partials/validation/test_invalid_contact_details_address_postcode.rst
@@ -1,9 +1,9 @@
-Scenario: An API consumer submitting a request with an invalid address postcode receives a 400 'Invalid Value' response
-===========================================================================================================================
+Scenario: An API consumer submitting a request with a non-string address postcode receives a 400 'Invalid Value' response
+=========================================================================================================================
-A valid contact detail must be structured in this format: { sms: value, email: value, address: { lines: [], postcode: value } }
+A valid address postcode contact detail must be structured in this format: { address: { postcode: Value } } where Value is a string
-| **Given** the API consumer provides an message body with an invalid postcode
+| **Given** the API consumer provides a message body with a non-string address postcode
| **When** the request is submitted
| **Then** the response returns a 400 invalid value error
@@ -17,6 +17,6 @@ A valid contact detail must be structured in this format: { sms: value, email: v
* - Value
- Description
- * - LS1 6AECD
- - Used to ensure only valid postcode is accepted
+ * - []
+ - Used to ensure only a string address postcode is accepted
diff --git a/tests/docs/partials/validation/test_invalid_contact_details_email.rst b/tests/docs/partials/validation/test_invalid_contact_details_email.rst
index a2cf7e596..6eff865a0 100644
--- a/tests/docs/partials/validation/test_invalid_contact_details_email.rst
+++ b/tests/docs/partials/validation/test_invalid_contact_details_email.rst
@@ -1,9 +1,9 @@
-Scenario: An API consumer submitting a request with an invalid email receives a 400 'Invalid Value' response
+Scenario: An API consumer submitting a request with a non-string email address receives a 400 'Invalid Value' response
======================================================================================================================
-A valid contact detail must be structured in this format: { email: Value }
+A valid email contact detail must be structured in this format: { email: Value } where Value is a string
-| **Given** the API consumer provides an message body with an invalid email address
+| **Given** the API consumer provides a message body with a non-string email address
| **When** the request is submitted
| **Then** the response returns a 400 invalid value error
@@ -17,6 +17,6 @@ A valid contact detail must be structured in this format: { email: Value }
* - Value
- Description
- * - invalidEmailAddress
- - Used to ensure invalid email address is not accepted
+ * - []
+ - Used to ensure only a string email address is accepted
diff --git a/tests/docs/partials/validation/test_invalid_contact_details_sms.rst b/tests/docs/partials/validation/test_invalid_contact_details_sms.rst
index 0c52652f8..2c62f53d3 100644
--- a/tests/docs/partials/validation/test_invalid_contact_details_sms.rst
+++ b/tests/docs/partials/validation/test_invalid_contact_details_sms.rst
@@ -1,9 +1,9 @@
-Scenario: An API consumer submitting a request with an invalid sms receives a 400 'Invalid Value' response
-======================================================================================================================
+Scenario: An API consumer submitting a request with a non-string sms receives a 400 'Invalid Value' response
+============================================================================================================
-A valid sms contact detail must be structured in this format: { sms: value }
+A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string
-| **Given** the API consumer provides an message body with an invalid sms
+| **Given** the API consumer provides a message body with a non-string sms
| **When** the request is submitted
| **Then** the response returns a 400 invalid value error
@@ -17,6 +17,6 @@ A valid sms contact detail must be structured in this format: { sms: value }
* - Value
- Description
- * - 077009000021
- - Used to ensure invalid phone number is not accepted
+ * - []
+ - Used to ensure only a string phone number is accepted
diff --git a/tests/docs/partials/validation/test_invalid_personalisation.rst b/tests/docs/partials/validation/test_invalid_personalisation.rst
index c40050bac..ecff04908 100644
--- a/tests/docs/partials/validation/test_invalid_personalisation.rst
+++ b/tests/docs/partials/validation/test_invalid_personalisation.rst
@@ -1,14 +1,14 @@
-Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 'Invalid value' response
+Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 'Invalid Value' response
======================================================================================================================
-A valid personalisation must be structured in this format: { parameter: value }
+A valid personalisation must be structured in this format: { parameter: Value }
| **Given** the API consumer provides a message body with an invalid personalisation
| **When** the request is submitted
| **Then** the response returns a 400 invalid value error
**Asserts**
-- Response returns a 400 'Invalid value' error
+- Response returns a 400 'Invalid Value' error
- Response returns the expected error message body with references to the invalid attribute
.. list-table::
diff --git a/tests/lib/constants/constants.py b/tests/lib/constants/constants.py
index 021189639..1ad914d0b 100644
--- a/tests/lib/constants/constants.py
+++ b/tests/lib/constants/constants.py
@@ -109,14 +109,6 @@ def __init__(self, code, status, title, detail, links={}):
"The property at the specified location is required, but was not present in the request."
)
-# too few address lines
-ERROR_TOO_FEW_ADDRESS_LINES = Error(
- "CM_MISSING_VALUE",
- "400",
- "Missing value",
- "Too few address lines were provided"
-)
-
# null value constants
ERROR_NULL_VALUE = Error(
"CM_NULL_VALUE",
diff --git a/tests/sandbox/message_batches/create_message_batches/test_field_validation.py b/tests/sandbox/message_batches/create_message_batches/test_field_validation.py
index a51e1235e..51e83b006 100644
--- a/tests/sandbox/message_batches/create_message_batches/test_field_validation.py
+++ b/tests/sandbox/message_batches/create_message_batches/test_field_validation.py
@@ -554,7 +554,7 @@ def test_invalid_sms_contact_details(nhsd_apim_proxy_url, correlation_id):
"recipient": {
"nhsNumber": "9990548609",
"contactDetails": {
- "sms": "11111111111"
+ "sms": 1234
}
},
}
@@ -568,7 +568,7 @@ def test_invalid_sms_contact_details(nhsd_apim_proxy_url, correlation_id):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/0/recipient/contactDetails/sms",
- "Input failed format check"
+ "'sms' is not a string"
),
correlation_id
)
@@ -595,7 +595,7 @@ def test_invalid_email_contact_details(nhsd_apim_proxy_url, correlation_id):
"recipient": {
"nhsNumber": "9990548609",
"contactDetails": {
- "email": "invalidEmailAddress"
+ "email": 1234
}
},
}
@@ -609,7 +609,7 @@ def test_invalid_email_contact_details(nhsd_apim_proxy_url, correlation_id):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/0/recipient/contactDetails/email",
- "Input failed format check"
+ "'email' is not a string"
),
correlation_id
)
@@ -617,9 +617,9 @@ def test_invalid_email_contact_details(nhsd_apim_proxy_url, correlation_id):
@pytest.mark.sandboxtest
@pytest.mark.parametrize("correlation_id", constants.CORRELATION_ID)
-def test_invalid_address_contact_details_too_few_lines(nhsd_apim_proxy_url, correlation_id):
+def test_invalid_address_contact_details_too_many_lines(nhsd_apim_proxy_url, correlation_id):
"""
- .. include:: ../../partials/validation/test_invalid_contact_details_address_lines_too_few.rst
+ .. include:: ../../partials/validation/test_invalid_contact_details_address_lines_too_many.rst
"""
resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={
**headers,
@@ -638,7 +638,12 @@ def test_invalid_address_contact_details_too_few_lines(nhsd_apim_proxy_url, corr
"contactDetails": {
"address": {
"lines": [
- "1"
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6"
],
"postcode": "test"
}
@@ -653,9 +658,9 @@ def test_invalid_address_contact_details_too_few_lines(nhsd_apim_proxy_url, corr
Assertions.assert_error_with_optional_correlation_id(
resp,
400,
- Generators.generate_too_few_items_error_custom_detail(
+ Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/0/recipient/contactDetails/address",
- "Too few address lines were provided"
+ "Too many address lines were provided"
),
correlation_id
)
@@ -663,9 +668,9 @@ def test_invalid_address_contact_details_too_few_lines(nhsd_apim_proxy_url, corr
@pytest.mark.sandboxtest
@pytest.mark.parametrize("correlation_id", constants.CORRELATION_ID)
-def test_invalid_address_contact_details_too_many_lines(nhsd_apim_proxy_url, correlation_id):
+def test_invalid_address_contact_details_lines_not_string_array(nhsd_apim_proxy_url, correlation_id):
"""
- .. include:: ../../partials/validation/test_invalid_contact_details_address_lines_too_many.rst
+ .. include:: ../../partials/validation/test_invalid_contact_details_address_lines.rst
"""
resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={
**headers,
@@ -683,14 +688,7 @@ def test_invalid_address_contact_details_too_many_lines(nhsd_apim_proxy_url, cor
"nhsNumber": "9990548609",
"contactDetails": {
"address": {
- "lines": [
- "1",
- "2",
- "3",
- "4",
- "5",
- "6"
- ],
+ "lines": [1, 2, 3],
"postcode": "test"
}
}
@@ -706,7 +704,7 @@ def test_invalid_address_contact_details_too_many_lines(nhsd_apim_proxy_url, cor
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/messages/0/recipient/contactDetails/address",
- "Too many address lines were provided"
+ "'lines' is not a string array"
),
correlation_id
)
diff --git a/tests/sandbox/messages/create_messages/test_field_validation.py b/tests/sandbox/messages/create_messages/test_field_validation.py
index 811fd20e3..707d83f6f 100644
--- a/tests/sandbox/messages/create_messages/test_field_validation.py
+++ b/tests/sandbox/messages/create_messages/test_field_validation.py
@@ -334,7 +334,7 @@ def test_invalid_sms_contact_details(nhsd_apim_proxy_url, correlation_id):
"recipient": {
"nhsNumber": "9990548609",
"contactDetails": {
- "sms": "11111111111"
+ "sms": 1234
}
},
}
@@ -346,7 +346,7 @@ def test_invalid_sms_contact_details(nhsd_apim_proxy_url, correlation_id):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/recipient/contactDetails/sms",
- "Input failed format check"
+ "'sms' is not a string"
),
correlation_id
)
@@ -370,7 +370,7 @@ def test_invalid_email_contact_details(nhsd_apim_proxy_url, correlation_id):
"recipient": {
"nhsNumber": "9990548609",
"contactDetails": {
- "email": "invalidEmailAddress"
+ "email": 1234
}
},
}
@@ -382,7 +382,7 @@ def test_invalid_email_contact_details(nhsd_apim_proxy_url, correlation_id):
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/recipient/contactDetails/email",
- "Input failed format check"
+ "'email' is not a string"
),
correlation_id
)
@@ -390,9 +390,9 @@ def test_invalid_email_contact_details(nhsd_apim_proxy_url, correlation_id):
@pytest.mark.sandboxtest
@pytest.mark.parametrize("correlation_id", constants.CORRELATION_ID)
-def test_invalid_address_contact_details_too_few_lines(nhsd_apim_proxy_url, correlation_id):
+def test_invalid_address_contact_details_too_many_lines(nhsd_apim_proxy_url, correlation_id):
"""
- .. include:: ../../partials/validation/test_invalid_contact_details_address_lines_too_few.rst
+ .. include:: ../../partials/validation/test_invalid_contact_details_address_lines_too_many.rst
"""
resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={
**headers,
@@ -408,7 +408,12 @@ def test_invalid_address_contact_details_too_few_lines(nhsd_apim_proxy_url, corr
"contactDetails": {
"address": {
"lines": [
- "1"
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6"
],
"postcode": "test"
}
@@ -421,9 +426,9 @@ def test_invalid_address_contact_details_too_few_lines(nhsd_apim_proxy_url, corr
Assertions.assert_error_with_optional_correlation_id(
resp,
400,
- Generators.generate_too_few_items_error_custom_detail(
+ Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/recipient/contactDetails/address",
- "Too few address lines were provided"
+ "Too many address lines were provided"
),
correlation_id
)
@@ -431,9 +436,9 @@ def test_invalid_address_contact_details_too_few_lines(nhsd_apim_proxy_url, corr
@pytest.mark.sandboxtest
@pytest.mark.parametrize("correlation_id", constants.CORRELATION_ID)
-def test_invalid_address_contact_details_too_many_lines(nhsd_apim_proxy_url, correlation_id):
+def test_invalid_address_contact_details_lines_not_string_array(nhsd_apim_proxy_url, correlation_id):
"""
- .. include:: ../../partials/validation/test_invalid_contact_details_address_lines_too_many.rst
+ .. include:: ../../partials/validation/test_invalid_contact_details_address_lines.rst
"""
resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={
**headers,
@@ -448,14 +453,7 @@ def test_invalid_address_contact_details_too_many_lines(nhsd_apim_proxy_url, cor
"nhsNumber": "9990548609",
"contactDetails": {
"address": {
- "lines": [
- "1",
- "2",
- "3",
- "4",
- "5",
- "6"
- ],
+ "lines": [1, 2, 3],
"postcode": "test"
}
}
@@ -469,7 +467,7 @@ def test_invalid_address_contact_details_too_many_lines(nhsd_apim_proxy_url, cor
400,
Generators.generate_invalid_value_error_custom_detail(
"/data/attributes/recipient/contactDetails/address",
- "Too many address lines were provided"
+ "'lines' is not a string array"
),
correlation_id
)