Skip to content

Commit

Permalink
API-39890-updates-some-valdations-for-change-of-address
Browse files Browse the repository at this point in the history
* Updates/adds validation for:
	* typeOfAddressChange
	* addressLine1
	* city
	* state
* Updates documentation description to reflect conditionally required attributes
* Adds tests
 Changes to be committed:
	modified:   modules/claims_api/app/controllers/concerns/claims_api/v2/disability_compensation_validation.rb
	modified:   modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
	modified:   modules/claims_api/app/swagger/claims_api/v2/production/swagger.json
	modified:   modules/claims_api/config/schemas/v2/526.json
	modified:   modules/claims_api/spec/lib/claims_api/v2/disability_compensation_validation_spec.rb
  • Loading branch information
rockwellwindsor-va committed Sep 5, 2024
1 parent 42e97a2 commit 5956a9e
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,39 @@ def validate_form_526_change_of_address

def validate_form_526_change_of_address_required_fields
change_of_address = form_attributes['changeOfAddress']
coa_begin_date = change_of_address&.dig('dates', 'beginDate') # we can have a valid form without an endDate

form_object_desc = '/changeOfAddress'

validate_form_526_coa_type_of_address_change_presence(change_of_address, form_object_desc)
validate_form_526_coa_address_line_one_presence(change_of_address, form_object_desc)
validate_form_526_coa_country_presence(change_of_address, form_object_desc)
validate_form_526_coa_city_presence(change_of_address, form_object_desc)

coa_begin_date = change_of_address&.dig('dates', 'beginDate') # we can have a valid form without an endDate

collect_error_if_value_not_present('begin date', form_object_desc) if coa_begin_date.blank?
end

def validate_form_526_coa_type_of_address_change_presence(change_of_address, form_object_desc)
type_of_address_change = change_of_address&.dig('typeOfAddressChange')
collect_error_if_value_not_present('typeOfAddressChange', form_object_desc) if type_of_address_change.blank?
end

def validate_form_526_coa_address_line_one_presence(change_of_address, form_object_desc)
address_line_one = change_of_address&.dig('addressLine1')
collect_error_if_value_not_present('addressLine1', form_object_desc) if address_line_one.blank?
end

def validate_form_526_coa_country_presence(change_of_address, form_object_desc)
country = change_of_address&.dig('country')
collect_error_if_value_not_present('country', form_object_desc) if country.blank?
end

def validate_form_526_coa_city_presence(change_of_address, form_object_desc)
city = change_of_address&.dig('city')
collect_error_if_value_not_present('city', form_object_desc) if city.blank?
end

def validate_form_526_change_of_address_beginning_date
change_of_address = form_attributes['changeOfAddress']
date = change_of_address.dig('dates', 'beginDate')
Expand Down Expand Up @@ -126,20 +152,41 @@ def validate_form_526_change_of_address_state

def validate_form_526_change_of_address_zip
address = form_attributes['changeOfAddress'] || {}
if address['country'] == 'USA' && address['zipFirstFive'].blank?
if address['country'] == 'USA'
validate_form_526_usa_zip_code(address)
else
validate_form_526_international_zip_code(address)
end
end

def validate_form_526_usa_zip_code(address)
if address['zipFirstFive'].blank?
collect_error_messages(
source: '/changeOfAddress/zipFirstFive',
detail: 'The zipFirstFive is required if the country is USA.'
)
elsif address['country'] != 'USA' && address['internationalPostalCode'].blank?
end

if address['internationalPostalCode'].present?
collect_error_messages(
source: '/changeOfAddress/internationalPostalCode',
detail: 'The internationalPostalCode is required if the country is not USA.'
detail: 'The internationalPostalCode should not be provided if the country is USA.'
)
elsif address['country'] == 'USA' && address['internationalPostalCode'].present?
end
end

def validate_form_526_international_zip_code(address)
if address['internationalPostalCode'].blank?
collect_error_messages(
source: '/changeOfAddress/internationalPostalCode',
detail: 'The internationalPostalCode should not be provided if the country is USA.'
detail: 'The internationalPostalCode is required if the country is not USA.'
)
end

if address['zipFirstFive'].present?
collect_error_messages(
source: '/changeOfAddress/zipFirstFive',
detail: 'The zipFirstFive is prohibited if the country is USA.'
)
end
end
Expand Down
30 changes: 15 additions & 15 deletions modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": "object",
"nullable": true,
"additionalProperties": false,
Expand Down Expand Up @@ -3559,7 +3559,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": "object",
"nullable": true,
"additionalProperties": false,
Expand Down Expand Up @@ -5069,7 +5069,7 @@
"202 without a transactionId": {
"value": {
"data": {
"id": "925698c0-acd8-4155-80ba-6aed534825da",
"id": "23671de3-100f-4a3e-885c-90172182aace",
"type": "forms/526",
"attributes": {
"claimId": "600442191",
Expand Down Expand Up @@ -5254,7 +5254,7 @@
},
"federalActivation": {
"activationDate": "2023-10-01",
"anticipatedSeparationDate": "2024-08-31"
"anticipatedSeparationDate": "2024-09-07"
},
"confinements": [
{
Expand Down Expand Up @@ -5300,7 +5300,7 @@
"202 with a transactionId": {
"value": {
"data": {
"id": "285b02b0-6a6b-4a57-ba90-77a7cfc01e0c",
"id": "e51d2e3c-b89d-49c6-b3fa-178967c3996c",
"type": "forms/526",
"attributes": {
"claimId": "600442191",
Expand Down Expand Up @@ -5714,7 +5714,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": "object",
"nullable": true,
"additionalProperties": false,
Expand Down Expand Up @@ -7094,7 +7094,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": "object",
"nullable": true,
"additionalProperties": false,
Expand Down Expand Up @@ -9251,7 +9251,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": "object",
"nullable": true,
"additionalProperties": false,
Expand Down Expand Up @@ -10506,7 +10506,7 @@
"application/json": {
"example": {
"data": {
"id": "4e010a53-2107-486a-b006-5e98b8394c15",
"id": "0ce9c6ec-7cad-4265-8646-5ddb4fbe1630",
"type": "forms/526",
"attributes": {
"claimProcessType": "STANDARD_CLAIM_PROCESS",
Expand Down Expand Up @@ -14166,8 +14166,8 @@
"id": "1",
"type": "intent_to_file",
"attributes": {
"creationDate": "2024-08-29",
"expirationDate": "2025-08-29",
"creationDate": "2024-09-05",
"expirationDate": "2025-09-05",
"type": "compensation",
"status": "active"
}
Expand Down Expand Up @@ -15063,7 +15063,7 @@
"application/json": {
"example": {
"data": {
"id": "fb3346c4-25c3-45fb-bb7c-99edeb99c5f5",
"id": "fc111130-739f-440a-81b2-68881f398606",
"type": "individual",
"attributes": {
"code": "067",
Expand Down Expand Up @@ -15756,7 +15756,7 @@
"application/json": {
"example": {
"data": {
"id": "14b7e4ed-1537-479c-ab98-fb65eb97ef18",
"id": "8063d080-0504-431e-9f13-6903506096fa",
"type": "organization",
"attributes": {
"code": "083",
Expand Down Expand Up @@ -17707,10 +17707,10 @@
"application/json": {
"example": {
"data": {
"id": "7ab0c254-3162-45fd-87dd-dc44d14cb2f9",
"id": "644fbbbf-84da-4e66-b3fc-725de338e3b8",
"type": "claimsApiPowerOfAttorneys",
"attributes": {
"dateRequestAccepted": "2024-08-29",
"dateRequestAccepted": "2024-09-05",
"previousPoa": null,
"representative": {
"serviceOrganization": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": "object",
"nullable": true,
"additionalProperties": false,
Expand Down Expand Up @@ -2172,7 +2172,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": "object",
"nullable": true,
"additionalProperties": false,
Expand Down Expand Up @@ -3682,7 +3682,7 @@
"202 without a transactionId": {
"value": {
"data": {
"id": "0db55941-4811-4fd9-80cd-f743761a64ea",
"id": "780f8d39-9512-4d83-bdb1-b07cc38590eb",
"type": "forms/526",
"attributes": {
"claimId": "600442191",
Expand Down Expand Up @@ -3867,7 +3867,7 @@
},
"federalActivation": {
"activationDate": "2023-10-01",
"anticipatedSeparationDate": "2024-08-31"
"anticipatedSeparationDate": "2024-09-07"
},
"confinements": [
{
Expand Down Expand Up @@ -3913,7 +3913,7 @@
"202 with a transactionId": {
"value": {
"data": {
"id": "01a05245-ad48-47c0-b044-60bd1a1cf4d5",
"id": "935b0e32-8ed6-458f-8e49-41496a9dcd44",
"type": "forms/526",
"attributes": {
"claimId": "600442191",
Expand Down Expand Up @@ -4327,7 +4327,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": "object",
"nullable": true,
"additionalProperties": false,
Expand Down Expand Up @@ -5707,7 +5707,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": "object",
"nullable": true,
"additionalProperties": false,
Expand Down Expand Up @@ -7864,7 +7864,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": "object",
"nullable": true,
"additionalProperties": false,
Expand Down Expand Up @@ -9119,7 +9119,7 @@
"application/json": {
"example": {
"data": {
"id": "746039f5-8aa5-49b5-abea-5ed07ac16b35",
"id": "da55e53d-ffd0-49b9-a1bb-0e6205bd8a93",
"type": "forms/526",
"attributes": {
"claimProcessType": "STANDARD_CLAIM_PROCESS",
Expand Down Expand Up @@ -12779,8 +12779,8 @@
"id": "1",
"type": "intent_to_file",
"attributes": {
"creationDate": "2024-08-29",
"expirationDate": "2025-08-29",
"creationDate": "2024-09-05",
"expirationDate": "2025-09-05",
"type": "compensation",
"status": "active"
}
Expand Down Expand Up @@ -13676,7 +13676,7 @@
"application/json": {
"example": {
"data": {
"id": "69b82793-223a-4d60-ab61-eb67ddb77fc6",
"id": "be9c1727-c4ab-4899-a9c1-a805295f6b4c",
"type": "individual",
"attributes": {
"code": "067",
Expand Down Expand Up @@ -14369,7 +14369,7 @@
"application/json": {
"example": {
"data": {
"id": "5cfd4d55-d0c5-4476-87c1-a1956c8dc02b",
"id": "b3afc80a-0859-4408-ac7a-bccf75837505",
"type": "organization",
"attributes": {
"code": "083",
Expand Down Expand Up @@ -16320,10 +16320,10 @@
"application/json": {
"example": {
"data": {
"id": "22563f3d-74c4-44b8-b2a0-0da7bfe639a4",
"id": "4cb7c195-730a-4061-8482-dfd5a26d75b6",
"type": "claimsApiPowerOfAttorneys",
"attributes": {
"dateRequestAccepted": "2024-08-29",
"dateRequestAccepted": "2024-09-05",
"previousPoa": null,
"representative": {
"serviceOrganization": {
Expand Down
2 changes: 1 addition & 1 deletion modules/claims_api/config/schemas/v2/526.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
}
},
"changeOfAddress": {
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'dates.beginDate', 'addressLine1', 'city', 'state', 'country', 'zipFirstFive'.",
"description": "If 'changeOfAddress' is included, the following attributes are required: 'typeOfAddressChange', 'addressLine1', 'city', 'country'.",
"type": ["object", "null"],
"nullable": true,
"additionalProperties": false,
Expand Down
Loading

0 comments on commit 5956a9e

Please sign in to comment.