From 8cdc253598ba1a1fb993cfe14f75d0ebb9669c5d Mon Sep 17 00:00:00 2001 From: Jarred Simon Date: Thu, 16 Nov 2023 11:01:10 -0600 Subject: [PATCH 1/6] #VYE-135 #comment added dist folder with schema and added tests for new schema --- dist/VYE-ADDRESS-CHANGE-schema.json | 1281 +++++++++++++++++ src/schemas/VYE-Address-Change/schema.js | 273 ++++ .../schemas/VYE-Address-Change/schema.spec.js | 109 ++ 3 files changed, 1663 insertions(+) create mode 100644 dist/VYE-ADDRESS-CHANGE-schema.json create mode 100644 src/schemas/VYE-Address-Change/schema.js create mode 100644 test/schemas/VYE-Address-Change/schema.spec.js diff --git a/dist/VYE-ADDRESS-CHANGE-schema.json b/dist/VYE-ADDRESS-CHANGE-schema.json new file mode 100644 index 000000000..50a517c35 --- /dev/null +++ b/dist/VYE-ADDRESS-CHANGE-schema.json @@ -0,0 +1,1281 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Verify Your Enrollment Change of Address", + "type": "object", + "additionalProperties": false, + "definitions": { + "fullName": { + "type": "object", + "properties": { + "first": { + "type": "string", + "minLength": 1, + "maxLength": 30, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + }, + "middle": { + "type": "string", + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$", + "maxLength": 20 + }, + "last": { + "type": "string", + "minLength": 1, + "maxLength": 30, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + } + }, + "required": [ + "first", + "last" + ] + }, + "ssn": { + "type": "string", + "pattern": "^[0-9]{9}$" + }, + "domesticAddress": { + "type": "object", + "required": [ + "addressType", + "street", + "city", + "countryDropdown", + "state", + "postalCode" + ], + "properties": { + "addressType": { + "type": "string", + "enum": [ + "DOMESTIC" + ], + "default": "DOMESTIC" + }, + "street": { + "type": "string", + "minLength": 1, + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street2": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street3": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street4": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "city": { + "type": "string", + "maxLength": 30, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + }, + "countryDropdown": { + "type": "string", + "maxLength": 50, + "default": "USA" + }, + "state": { + "type": "string", + "maxLength": 50, + "enum": [ + "AL", + "AK", + "AS", + "AZ", + "AR", + "AA", + "AE", + "AP", + "CA", + "CO", + "CT", + "DE", + "DC", + "FM", + "FL", + "GA", + "GU", + "HI", + "ID", + "IL", + "IN", + "IA", + "KS", + "KY", + "LA", + "ME", + "MH", + "MD", + "MA", + "MI", + "MN", + "MS", + "MO", + "MT", + "NE", + "NV", + "NH", + "NJ", + "NM", + "NY", + "NC", + "ND", + "MP", + "OH", + "OK", + "OR", + "PW", + "PA", + "PR", + "RI", + "SC", + "SD", + "TN", + "TX", + "UM", + "UT", + "VT", + "VI", + "VA", + "WA", + "WV", + "WI", + "WY" + ], + "enumNames": [ + "Alabama", + "Alaska", + "American Samoa", + "Arizona", + "Arkansas", + "Armed Forces Americas (AA)", + "Armed Forces Europe (AE)", + "Armed Forces Pacific (AP)", + "California", + "Colorado", + "Connecticut", + "Delaware", + "District Of Columbia", + "Federated States Of Micronesia", + "Florida", + "Georgia", + "Guam", + "Hawaii", + "Idaho", + "Illinois", + "Indiana", + "Iowa", + "Kansas", + "Kentucky", + "Louisiana", + "Maine", + "Marshall Islands", + "Maryland", + "Massachusetts", + "Michigan", + "Minnesota", + "Mississippi", + "Missouri", + "Montana", + "Nebraska", + "Nevada", + "New Hampshire", + "New Jersey", + "New Mexico", + "New York", + "North Carolina", + "North Dakota", + "Northern Mariana Islands", + "Ohio", + "Oklahoma", + "Oregon", + "Palau", + "Pennsylvania", + "Puerto Rico", + "Rhode Island", + "South Carolina", + "South Dakota", + "Tennessee", + "Texas", + "United States Minor Outlying Islands", + "Utah", + "Vermont", + "Virgin Islands", + "Virginia", + "Washington", + "West Virginia", + "Wisconsin", + "Wyoming" + ] + }, + "postalCode": { + "$ref": "#/definitions/postalCode" + } + }, + "additionalProperties": false + }, + "militaryAddress": { + "type": "object", + "required": [ + "addressType", + "street", + "city", + "countryDropdown", + "postOffice", + "postalType", + "postalCode" + ], + "properties": { + "addressType": { + "type": "string", + "enum": [ + "MILITARY" + ], + "default": "MILITARY" + }, + "street": { + "type": "string", + "minLength": 1, + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street2": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street3": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street4": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "city": { + "type": "string", + "maxLength": 30, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + }, + "countryDropdown": { + "type": "string", + "maxLength": 50, + "enum": [ + "USA", + "Country Not In List", + "Afghanistan", + "Albania", + "Algeria", + "Angola", + "Anguilla", + "Antigua", + "Antigua and Barbuda", + "Argentina", + "Armenia", + "Australia", + "Austria", + "Azerbaijan", + "Azores", + "Bahamas", + "Bahrain", + "Bangladesh", + "Barbados", + "Barbuda", + "Belarus", + "Belgium", + "Belize", + "Benin", + "Bermuda", + "Bhutan", + "Bolivia", + "Bosnia-Herzegovina", + "Botswana", + "Brazil", + "Brunei", + "Bulgaria", + "Burkina Faso", + "Burma", + "Burundi", + "Cambodia", + "Cameroon", + "Canada", + "Cape Verde", + "Cayman Islands", + "Central African Republic", + "Chad", + "Chile", + "China", + "Colombia", + "Comoros", + "Congo, Democratic Republic of", + "Congo, People's Republic of", + "Costa Rica", + "Cote d'Ivoire", + "Croatia", + "Cuba", + "Cyprus", + "Czech Republic", + "Denmark", + "Djibouti", + "Dominica", + "Dominican Republic", + "Ecuador", + "Egypt", + "El Salvador", + "England", + "Equatorial Guinea", + "Eritrea", + "Estonia", + "Ethiopia", + "Fiji", + "Finland", + "France", + "French Guiana", + "Gabon", + "Gambia", + "Georgia", + "Germany", + "Ghana", + "Gibraltar", + "Great Britain", + "Great Britain and Gibraltar", + "Greece", + "Greenland", + "Grenada", + "Guadeloupe", + "Guatemala", + "Guinea", + "Guinea, Republic of Guinea", + "Guinea-Bissau", + "Guyana", + "Haiti", + "Honduras", + "Hong Kong", + "Hungary", + "Iceland", + "India", + "Indonesia", + "Iran", + "Iraq", + "Ireland", + "Israel (Jerusalem)", + "Israel (Tel Aviv)", + "Italy", + "Jamaica", + "Japan", + "Jordan", + "Kazakhstan", + "Kenya", + "Kosovo", + "Kuwait", + "Kyrgyzstan", + "Laos", + "Latvia", + "Lebanon", + "Leeward Islands", + "Lesotho", + "Liberia", + "Libya", + "Liechtenstein", + "Lithuania", + "Luxembourg", + "Macao", + "Macedonia", + "Madagascar", + "Malawi", + "Malaysia", + "Mali", + "Malta", + "Martinique", + "Mauritania", + "Mauritius", + "Mexico", + "Moldavia", + "Mongolia", + "Montenegro", + "Montserrat", + "Morocco", + "Mozambique", + "Namibia", + "Nepal", + "Netherlands", + "Netherlands Antilles", + "Nevis", + "New Caledonia", + "New Zealand", + "Nicaragua", + "Niger", + "Nigeria", + "North Korea", + "Northern Ireland", + "Norway", + "Oman", + "Pakistan", + "Panama", + "Papua New Guinea", + "Paraguay", + "Peru", + "Philippines", + "Philippines (restricted payments)", + "Poland", + "Portugal", + "Qatar", + "Republic of Yemen", + "Romania", + "Russia", + "Rwanda", + "Sao-Tome/Principe", + "Saudi Arabia", + "Scotland", + "Senegal", + "Serbia", + "Serbia/Montenegro", + "Seychelles", + "Sicily", + "Sierra Leone", + "Singapore", + "Slovakia", + "Slovenia", + "Somalia", + "South Africa", + "South Korea", + "Spain", + "Sri Lanka", + "St. Kitts", + "St. Lucia", + "St. Vincent", + "Sudan", + "Suriname", + "Swaziland", + "Sweden", + "Switzerland", + "Syria", + "Taiwan", + "Tajikistan", + "Tanzania", + "Thailand", + "Togo", + "Trinidad and Tobago", + "Tunisia", + "Turkey (Adana only)", + "Turkey (except Adana)", + "Turkmenistan", + "Uganda", + "Ukraine", + "United Arab Emirates", + "United Kingdom", + "Uruguay", + "Uzbekistan", + "Vanuatu", + "Venezuela", + "Vietnam", + "Wales", + "Western Samoa", + "Yemen Arab Republic", + "Zambia", + "Zimbabwe" + ] + }, + "postOffice": { + "type": "string", + "enum": [ + "APO", + "DPO", + "FPO" + ], + "enumNames": [ + "Ashore Post Office", + "Diplomatic Post Office", + "Fleet Post Office" + ] + }, + "postalType": { + "type": "string", + "enum": [ + "AA", + "AE", + "AP" + ], + "enumNames": [ + "Armed Forces Americas (except Canada)", + "Armed Forces Europe, Middle East, Canada & Africa", + "Armed Forces Pacific" + ] + }, + "postalCode": { + "$ref": "#/definitions/postalCode" + } + }, + "additionalProperties": false + }, + "internationalAddressDropDown": { + "type": "object", + "required": [ + "addressType", + "street", + "city", + "countryDropdown" + ], + "properties": { + "addressType": { + "type": "string", + "enum": [ + "INTERNATIONAL" + ], + "default": "INTERNATIONAL" + }, + "street": { + "type": "string", + "minLength": 1, + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street2": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street3": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street4": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "city": { + "type": "string", + "maxLength": 30, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + }, + "countryDropdown": { + "type": "string", + "enum": [ + "Afghanistan", + "Albania", + "Algeria", + "Angola", + "Anguilla", + "Antigua", + "Antigua and Barbuda", + "Argentina", + "Armenia", + "Australia", + "Austria", + "Azerbaijan", + "Azores", + "Bahamas", + "Bahrain", + "Bangladesh", + "Barbados", + "Barbuda", + "Belarus", + "Belgium", + "Belize", + "Benin", + "Bermuda", + "Bhutan", + "Bolivia", + "Bosnia-Herzegovina", + "Botswana", + "Brazil", + "Brunei", + "Bulgaria", + "Burkina Faso", + "Burma", + "Burundi", + "Cambodia", + "Cameroon", + "Canada", + "Cape Verde", + "Cayman Islands", + "Central African Republic", + "Chad", + "Chile", + "China", + "Colombia", + "Comoros", + "Congo, Democratic Republic of", + "Congo, People's Republic of", + "Costa Rica", + "Cote d'Ivoire", + "Croatia", + "Cuba", + "Cyprus", + "Czech Republic", + "Denmark", + "Djibouti", + "Dominica", + "Dominican Republic", + "Ecuador", + "Egypt", + "El Salvador", + "England", + "Equatorial Guinea", + "Eritrea", + "Estonia", + "Ethiopia", + "Fiji", + "Finland", + "France", + "French Guiana", + "Gabon", + "Gambia", + "Georgia", + "Germany", + "Ghana", + "Gibraltar", + "Great Britain", + "Great Britain and Gibraltar", + "Greece", + "Greenland", + "Grenada", + "Guadeloupe", + "Guatemala", + "Guinea", + "Guinea, Republic of Guinea", + "Guinea-Bissau", + "Guyana", + "Haiti", + "Honduras", + "Hong Kong", + "Hungary", + "Iceland", + "India", + "Indonesia", + "Iran", + "Iraq", + "Ireland", + "Israel (Jerusalem)", + "Israel (Tel Aviv)", + "Italy", + "Jamaica", + "Japan", + "Jordan", + "Kazakhstan", + "Kenya", + "Kosovo", + "Kuwait", + "Kyrgyzstan", + "Laos", + "Latvia", + "Lebanon", + "Leeward Islands", + "Lesotho", + "Liberia", + "Libya", + "Liechtenstein", + "Lithuania", + "Luxembourg", + "Macao", + "Macedonia", + "Madagascar", + "Malawi", + "Malaysia", + "Mali", + "Malta", + "Martinique", + "Mauritania", + "Mauritius", + "Mexico", + "Moldavia", + "Mongolia", + "Montenegro", + "Montserrat", + "Morocco", + "Mozambique", + "Namibia", + "Nepal", + "Netherlands", + "Netherlands Antilles", + "Nevis", + "New Caledonia", + "New Zealand", + "Nicaragua", + "Niger", + "Nigeria", + "North Korea", + "Northern Ireland", + "Norway", + "Oman", + "Pakistan", + "Panama", + "Papua New Guinea", + "Paraguay", + "Peru", + "Philippines", + "Philippines (restricted payments)", + "Poland", + "Portugal", + "Qatar", + "Republic of Yemen", + "Romania", + "Russia", + "Rwanda", + "Sao-Tome/Principe", + "Saudi Arabia", + "Scotland", + "Senegal", + "Serbia", + "Serbia/Montenegro", + "Seychelles", + "Sicily", + "Sierra Leone", + "Singapore", + "Slovakia", + "Slovenia", + "Somalia", + "South Africa", + "South Korea", + "Spain", + "Sri Lanka", + "St. Kitts", + "St. Lucia", + "St. Vincent", + "Sudan", + "Suriname", + "Swaziland", + "Sweden", + "Switzerland", + "Syria", + "Taiwan", + "Tajikistan", + "Tanzania", + "Thailand", + "Togo", + "Trinidad and Tobago", + "Tunisia", + "Turkey (Adana only)", + "Turkey (except Adana)", + "Turkmenistan", + "Uganda", + "Ukraine", + "United Arab Emirates", + "United Kingdom", + "Uruguay", + "Uzbekistan", + "Vanuatu", + "Venezuela", + "Vietnam", + "Wales", + "Western Samoa", + "Yemen Arab Republic", + "Zambia", + "Zimbabwe" + ] + } + }, + "additionalProperties": false + }, + "internationalAddressText": { + "type": "object", + "required": [ + "addressType", + "street", + "city", + "countryDropdown", + "countryText" + ], + "properties": { + "addressType": { + "type": "string", + "enum": [ + "INTERNATIONAL" + ], + "default": "INTERNATIONAL" + }, + "street": { + "type": "string", + "minLength": 1, + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street2": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street3": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "street4": { + "type": "string", + "maxLength": 20, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" + }, + "city": { + "type": "string", + "maxLength": 30, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + }, + "countryDropdown": { + "type": "string", + "enum": [ + "Country Not In List" + ], + "default": "Country Not In List" + }, + "countryText": { + "type": "string", + "maxLength": 50, + "minLength": 1, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + } + }, + "additionalProperties": false + }, + "postalCode": { + "type": "string", + "maxLength": 10, + "pattern": "^\\d{5}(?:[- ]?\\d{4})?$" + }, + "location": { + "type": "object", + "properties": {}, + "oneOf": [ + { + "required": [ + "countryDropdown", + "city", + "state" + ], + "properties": { + "countryDropdown": { + "type": "string", + "enum": [ + "USA" + ], + "default": "USA" + }, + "city": { + "type": "string", + "maxLength": 30, + "minLength": 1, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + }, + "state": { + "type": "string", + "maxLength": 50, + "enum": [ + "AL", + "AK", + "AZ", + "AR", + "CA", + "CO", + "CT", + "DE", + "DC", + "FL", + "GA", + "HI", + "ID", + "IL", + "IN", + "IA", + "KS", + "KY", + "LA", + "ME", + "MD", + "MA", + "MI", + "MN", + "MS", + "MO", + "MT", + "NE", + "NV", + "NH", + "NJ", + "NM", + "NY", + "NC", + "ND", + "OH", + "OK", + "OR", + "PA", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VT", + "VA", + "WA", + "WV", + "WI", + "WY" + ], + "enumNames": [ + "Alabama", + "Alaska", + "Arizona", + "Arkansas", + "California", + "Colorado", + "Connecticut", + "Delaware", + "District Of Columbia", + "Florida", + "Georgia", + "Hawaii", + "Idaho", + "Illinois", + "Indiana", + "Iowa", + "Kansas", + "Kentucky", + "Louisiana", + "Maine", + "Maryland", + "Massachusetts", + "Michigan", + "Minnesota", + "Mississippi", + "Missouri", + "Montana", + "Nebraska", + "Nevada", + "New Hampshire", + "New Jersey", + "New Mexico", + "New York", + "North Carolina", + "North Dakota", + "Ohio", + "Oklahoma", + "Oregon", + "Pennsylvania", + "Rhode Island", + "South Carolina", + "South Dakota", + "Tennessee", + "Texas", + "Utah", + "Vermont", + "Virginia", + "Washington", + "West Virginia", + "Wisconsin", + "Wyoming" + ] + } + }, + "additionalProperties": false + }, + { + "required": [ + "countryDropdown", + "countryText" + ], + "properties": { + "countryDropdown": { + "type": "string", + "enum": [ + "Country Not In List" + ], + "default": "Country Not In List" + }, + "countryText": { + "type": "string", + "maxLength": 50, + "minLength": 1, + "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + } + }, + "additionalProperties": false + }, + { + "required": [ + "countryDropdown" + ], + "properties": { + "countryDropdown": { + "type": "string", + "enum": [ + "Afghanistan", + "Albania", + "Algeria", + "Angola", + "Anguilla", + "Antigua", + "Antigua and Barbuda", + "Argentina", + "Armenia", + "Australia", + "Austria", + "Azerbaijan", + "Azores", + "Bahamas", + "Bahrain", + "Bangladesh", + "Barbados", + "Barbuda", + "Belarus", + "Belgium", + "Belize", + "Benin", + "Bermuda", + "Bhutan", + "Bolivia", + "Bosnia-Herzegovina", + "Botswana", + "Brazil", + "Brunei", + "Bulgaria", + "Burkina Faso", + "Burma", + "Burundi", + "Cambodia", + "Cameroon", + "Canada", + "Cape Verde", + "Cayman Islands", + "Central African Republic", + "Chad", + "Chile", + "China", + "Colombia", + "Comoros", + "Congo, Democratic Republic of", + "Congo, People's Republic of", + "Costa Rica", + "Cote d'Ivoire", + "Croatia", + "Cuba", + "Cyprus", + "Czech Republic", + "Denmark", + "Djibouti", + "Dominica", + "Dominican Republic", + "Ecuador", + "Egypt", + "El Salvador", + "England", + "Equatorial Guinea", + "Eritrea", + "Estonia", + "Ethiopia", + "Fiji", + "Finland", + "France", + "French Guiana", + "Gabon", + "Gambia", + "Georgia", + "Germany", + "Ghana", + "Gibraltar", + "Great Britain", + "Great Britain and Gibraltar", + "Greece", + "Greenland", + "Grenada", + "Guadeloupe", + "Guatemala", + "Guinea", + "Guinea, Republic of Guinea", + "Guinea-Bissau", + "Guyana", + "Haiti", + "Honduras", + "Hong Kong", + "Hungary", + "Iceland", + "India", + "Indonesia", + "Iran", + "Iraq", + "Ireland", + "Israel (Jerusalem)", + "Israel (Tel Aviv)", + "Italy", + "Jamaica", + "Japan", + "Jordan", + "Kazakhstan", + "Kenya", + "Kosovo", + "Kuwait", + "Kyrgyzstan", + "Laos", + "Latvia", + "Lebanon", + "Leeward Islands", + "Lesotho", + "Liberia", + "Libya", + "Liechtenstein", + "Lithuania", + "Luxembourg", + "Macao", + "Macedonia", + "Madagascar", + "Malawi", + "Malaysia", + "Mali", + "Malta", + "Martinique", + "Mauritania", + "Mauritius", + "Mexico", + "Moldavia", + "Mongolia", + "Montenegro", + "Montserrat", + "Morocco", + "Mozambique", + "Namibia", + "Nepal", + "Netherlands", + "Netherlands Antilles", + "Nevis", + "New Caledonia", + "New Zealand", + "Nicaragua", + "Niger", + "Nigeria", + "North Korea", + "Northern Ireland", + "Norway", + "Oman", + "Pakistan", + "Panama", + "Papua New Guinea", + "Paraguay", + "Peru", + "Philippines", + "Philippines (restricted payments)", + "Poland", + "Portugal", + "Qatar", + "Republic of Yemen", + "Romania", + "Russia", + "Rwanda", + "Sao-Tome/Principe", + "Saudi Arabia", + "Scotland", + "Senegal", + "Serbia", + "Serbia/Montenegro", + "Seychelles", + "Sicily", + "Sierra Leone", + "Singapore", + "Slovakia", + "Slovenia", + "Somalia", + "South Africa", + "South Korea", + "Spain", + "Sri Lanka", + "St. Kitts", + "St. Lucia", + "St. Vincent", + "Sudan", + "Suriname", + "Swaziland", + "Sweden", + "Switzerland", + "Syria", + "Taiwan", + "Tajikistan", + "Tanzania", + "Thailand", + "Togo", + "Trinidad and Tobago", + "Tunisia", + "Turkey (Adana only)", + "Turkey (except Adana)", + "Turkmenistan", + "Uganda", + "Ukraine", + "United Arab Emirates", + "United Kingdom", + "Uruguay", + "Uzbekistan", + "Vanuatu", + "Venezuela", + "Vietnam", + "Wales", + "Western Samoa", + "Yemen Arab Republic", + "Zambia", + "Zimbabwe" + ] + } + }, + "additionalProperties": false + } + ] + }, + "vaFileNumber": { + "type": "string", + "pattern": "^[cC]{0,1}\\d{7,9}$" + } + }, + "properties": { + "veteranAddress": { + "type": "object", + "oneOf": [ + { + "$ref": "#/definitions/domesticAddress" + }, + { + "$ref": "#/definitions/militaryAddress" + }, + { + "$ref": "#/definitions/internationalAddressDropDown" + }, + { + "$ref": "#/definitions/internationalAddressText" + } + ] + }, + "veteranSocialSecurityNumber": { + "$ref": "#/definitions/ssn" + }, + "veteranFullName": { + "$ref": "#/definitions/fullName" + }, + "vaFileNumber": { + "$ref": "#/definitions/vaFileNumber" + } + }, + "required": [ + "veteranFullName", + "veteranAddress" + ], + "anyOf": [ + { + "required": [ + "vaFileNumber" + ] + }, + { + "required": [ + "veteranSocialSecurityNumber" + ] + } + ] +} diff --git a/src/schemas/VYE-Address-Change/schema.js b/src/schemas/VYE-Address-Change/schema.js new file mode 100644 index 000000000..00fb4a767 --- /dev/null +++ b/src/schemas/VYE-Address-Change/schema.js @@ -0,0 +1,273 @@ +import _ from 'lodash'; +import schemaHelpers from '../../common/schema-helpers'; +import originalDefinitions from '../../common/definitions'; +import constants from '../../common/constants'; + +const { states: constStates, states50AndDC, pciuCountries } = constants; + +// lists of countries and states are from EVSS ReferenceDataService +// if any of these countries are selected, addressType should be 'INTERNATIONAL' +const nonUSACountries = pciuCountries.filter(country => country !== 'USA'); +const countryUSA = pciuCountries.find(country => country === 'USA'); // if selected, addressType should be 'DOMESTIC' +const countryNotInList = 'Country Not In List'; // if selected, addressType should be 'INTERNATIONAL' + +const states = constStates.USA.concat([ + { value: 'UM', label: 'United States Minor Outlying Islands' }, +]).sort((stateA, stateB) => stateA.label.localeCompare(stateB.label)); + +const textRegex = '^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$'; +const textAndNumbersRegex = '^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$'; + +let definitions = _.cloneDeep(originalDefinitions); +definitions = _.pick(definitions, 'fullName', 'ssn'); + +definitions.fullName.properties.first.pattern = textRegex; +definitions.fullName.properties.last.pattern = textRegex; +definitions.fullName.properties.middle.pattern = textRegex; +definitions.fullName.properties.first.maxLength = 30; +definitions.fullName.properties.last.maxLength = 30; +definitions.fullName.properties.middle.maxLength = 20; +delete definitions.fullName.properties.suffix; + +const commonAddressFields = { + required: ['addressType', 'street', 'city', 'countryDropdown'], + properties: { + addressType: { + type: 'string', + enum: ['DOMESTIC', 'MILITARY', 'INTERNATIONAL'], + enumNames: ['Domestic', 'Military', 'International'], + }, + street: { + type: 'string', + minLength: 1, + maxLength: 20, + pattern: textAndNumbersRegex, + }, + street2: { + type: 'string', + maxLength: 20, + pattern: textAndNumbersRegex, + }, + street3: { + type: 'string', + maxLength: 20, + pattern: textAndNumbersRegex, + }, + street4: { + type: 'string', + maxLength: 20, + pattern: textAndNumbersRegex, + }, + city: { + type: 'string', + maxLength: 30, + pattern: textRegex, + }, + countryDropdown: { + type: 'string', + maxLength: 50, + enum: [countryUSA, countryNotInList].concat(nonUSACountries), + }, + }, +}; + +const addressDefs = [ + { $ref: '#/definitions/domesticAddress' }, + { $ref: '#/definitions/militaryAddress' }, + { $ref: '#/definitions/internationalAddressDropDown' }, + { $ref: '#/definitions/internationalAddressText' }, +]; + +const schema = { + $schema: 'http://json-schema.org/draft-04/schema#', + title: 'Verify Your Enrollment Change of Address', + type: 'object', + additionalProperties: false, + definitions: _.merge(definitions, { + domesticAddress: { + type: 'object', + required: [...commonAddressFields.required, 'state', 'postalCode'], + properties: { + ...commonAddressFields.properties, + addressType: { + type: 'string', + enum: ['DOMESTIC'], + default: 'DOMESTIC', + }, + state: { + type: 'string', + maxLength: 50, + enum: states.map(state => state.value), + enumNames: states.map(state => state.label), + }, + postalCode: { + $ref: '#/definitions/postalCode', + }, + countryDropdown: { + type: 'string', + maxLength: 50, + default: countryUSA, + }, + }, + additionalProperties: false, + }, + militaryAddress: { + type: 'object', + required: [...commonAddressFields.required, 'postOffice', 'postalType', 'postalCode'], + properties: { + ...commonAddressFields.properties, + addressType: { + type: 'string', + enum: ['MILITARY'], + default: 'MILITARY', + }, + postOffice: { + type: 'string', + enum: ['APO', 'DPO', 'FPO'], + enumNames: ['Ashore Post Office', 'Diplomatic Post Office', 'Fleet Post Office'], + }, + postalType: { + type: 'string', + enum: ['AA', 'AE', 'AP'], + enumNames: [ + 'Armed Forces Americas (except Canada)', + 'Armed Forces Europe, Middle East, Canada & Africa', + 'Armed Forces Pacific', + ], + }, + postalCode: { + $ref: '#/definitions/postalCode', + }, + }, + additionalProperties: false, + }, + internationalAddressDropDown: { + type: 'object', + required: [...commonAddressFields.required], + properties: { + ...commonAddressFields.properties, + addressType: { + type: 'string', + enum: ['INTERNATIONAL'], + default: 'INTERNATIONAL', + }, + countryDropdown: { + type: 'string', + enum: nonUSACountries, + }, + }, + additionalProperties: false, + }, + internationalAddressText: { + type: 'object', + required: [...commonAddressFields.required, 'countryText'], + properties: { + ...commonAddressFields.properties, + addressType: { + type: 'string', + enum: ['INTERNATIONAL'], + default: 'INTERNATIONAL', + }, + countryDropdown: { + type: 'string', + enum: [countryNotInList], + default: countryNotInList, + }, + countryText: { + type: 'string', + maxLength: 50, + minLength: 1, + pattern: textRegex, + }, + }, + additionalProperties: false, + }, + postalCode: { + type: 'string', + maxLength: 10, + pattern: '^\\d{5}(?:[- ]?\\d{4})?$', + }, + location: { + type: 'object', + properties: {}, + oneOf: [ + { + required: ['countryDropdown', 'city', 'state'], + properties: { + countryDropdown: { + type: 'string', + enum: [countryUSA], + default: countryUSA, + }, + city: { + type: 'string', + maxLength: 30, + minLength: 1, + pattern: textRegex, + }, + state: { + type: 'string', + maxLength: 50, + enum: states50AndDC.map(state => state.value), + enumNames: states50AndDC.map(state => state.label), + }, + }, + additionalProperties: false, + }, + { + required: ['countryDropdown', 'countryText'], + properties: { + countryDropdown: { + type: 'string', + enum: [countryNotInList], + default: countryNotInList, + }, + countryText: { + type: 'string', + maxLength: 50, + minLength: 1, + pattern: textRegex, + }, + }, + additionalProperties: false, + }, + { + required: ['countryDropdown'], + properties: { + countryDropdown: { + type: 'string', + enum: nonUSACountries, + }, + }, + additionalProperties: false, + }, + ], + }, + }), + properties: { + veteranAddress: { + type: 'object', + oneOf: addressDefs, + }, + veteranSocialSecurityNumber: { $ref: '#/definitions/ssn' }, + }, + required: ['veteranFullName', 'veteranAddress'], + anyOf: [ + { + required: ['vaFileNumber'], + }, + { + required: ['veteranSocialSecurityNumber'], + }, + ], +}; + +[ + + ['fullName', 'veteranFullName'], + ['vaFileNumber'], +].forEach(args => { + schemaHelpers.addDefinitionToSchema(schema, ...args); +}); + +export default schema; diff --git a/test/schemas/VYE-Address-Change/schema.spec.js b/test/schemas/VYE-Address-Change/schema.spec.js new file mode 100644 index 000000000..16bd5417b --- /dev/null +++ b/test/schemas/VYE-Address-Change/schema.spec.js @@ -0,0 +1,109 @@ +import _ from 'lodash'; +import { expect } from 'chai'; +import SchemaTestHelper from '../../support/schema-test-helper'; +import schemas from '../../../dist/schemas'; +import fixtures from '../../support/fixtures'; +import SharedTests from '../../support/shared-tests'; + +const schema = schemas['VYE-Address-Change']; +const schemaWithoutRequired = _.cloneDeep(schema); +delete schemaWithoutRequired.required; +delete schemaWithoutRequired.anyOf; + +const schemaTestHelper = new SchemaTestHelper(schemaWithoutRequired); +const sharedTests = new SharedTests(schemaTestHelper); + +describe('21-686C schema', () => { + it('should have the right required fields', () => { + expect(schema.required).to.deep.equal([ + 'veteranFullName', + 'veteranAddress', + ]); + }); + + sharedTests.runTest('fullName', ['veteranFullName']); + sharedTests.runTest('vaFileNumber', ['vaFileNumber']); + sharedTests.runTest('ssn', ['veteranSocialSecurityNumber']); + + schemaTestHelper.testValidAndInvalid('veteranAddress', { + valid: [ + { + addressType: 'DOMESTIC', + street: '123 main st.', + city: 'anywhere', + countryDropdown: 'USA', + state: 'KY', + postalCode: '55555', + }, + { + addressType: 'MILITARY', + street: '123 main st.', + city: 'anywhere', + countryDropdown: 'USA', + postOffice: 'APO', + postalType: 'AA', + postalCode: '55555', + }, + { + addressType: 'INTERNATIONAL', + street: '123 main st.', + city: 'anywhere', + countryDropdown: 'Canada', + }, + { + addressType: 'INTERNATIONAL', + street: '123 main st.', + city: 'anywhere', + countryDropdown: 'Country Not In List', + countryText: 'Independent Nation of Myself', + }, + ], + invalid: [ + // INTERNATIONAL with country of 'USA' + { + addressType: 'INTERNATIONAL', + street: '123 main st.', + city: 'anywhere', + countryDropdown: 'USA', + }, + + // INTERNATIONAL (Country Not In List) with state and postalCode + { + addressType: 'INTERNATIONAL', + street: '123 main st.', + city: 'anywhere', + countryDropdown: 'Country Not In List', + state: 'KY', + postalCode: '55555', + }, + + // INTERNATIONAL with state and postalCode + { + addressType: 'INTERNATIONAL', + street: '123 main st.', + city: 'anywhere', + state: 'KY', + countryDropdown: 'Bangladesh', + }, + + // INTERNATIONAL with selected country (allowed) and countryText (not allowed) + { + addressType: 'INTERNATIONAL', + street: '123 main st.', + city: 'anywhere', + countryDropdown: 'Canada', + countryText: 'Independent Nation of Myself', + }, + + // consecutive spaces present + { + addressType: 'DOMESTIC', + street: '123 main st.', + city: 'any where', + countryDropdown: 'USA', + state: 'KY', + postalCode: '55555', + }, + ], + }); +}); From 0ffdf35172fd2d2c543fd0e137f06856733b2beb Mon Sep 17 00:00:00 2001 From: Jarred Simon Date: Thu, 16 Nov 2023 12:34:03 -0600 Subject: [PATCH 2/6] #VYE-135 #comment fixed failing test based on wrong schema name --- test/schemas/VYE-Address-Change/schema.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/schemas/VYE-Address-Change/schema.spec.js b/test/schemas/VYE-Address-Change/schema.spec.js index 16bd5417b..aaaccaf44 100644 --- a/test/schemas/VYE-Address-Change/schema.spec.js +++ b/test/schemas/VYE-Address-Change/schema.spec.js @@ -2,10 +2,9 @@ import _ from 'lodash'; import { expect } from 'chai'; import SchemaTestHelper from '../../support/schema-test-helper'; import schemas from '../../../dist/schemas'; -import fixtures from '../../support/fixtures'; import SharedTests from '../../support/shared-tests'; -const schema = schemas['VYE-Address-Change']; +const schema = schemas['VYE-ADDRESS-CHANGE']; const schemaWithoutRequired = _.cloneDeep(schema); delete schemaWithoutRequired.required; delete schemaWithoutRequired.anyOf; From bba8c776ee71d6ca697a5066c1f8cf95d68eff1d Mon Sep 17 00:00:00 2001 From: Jarred Simon Date: Fri, 17 Nov 2023 09:38:20 -0600 Subject: [PATCH 3/6] #VYE-135 #comment Deleted unneed comment in the code --- src/schemas/VYE-Address-Change/schema.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/schemas/VYE-Address-Change/schema.js b/src/schemas/VYE-Address-Change/schema.js index 00fb4a767..67130defe 100644 --- a/src/schemas/VYE-Address-Change/schema.js +++ b/src/schemas/VYE-Address-Change/schema.js @@ -5,7 +5,6 @@ import constants from '../../common/constants'; const { states: constStates, states50AndDC, pciuCountries } = constants; -// lists of countries and states are from EVSS ReferenceDataService // if any of these countries are selected, addressType should be 'INTERNATIONAL' const nonUSACountries = pciuCountries.filter(country => country !== 'USA'); const countryUSA = pciuCountries.find(country => country === 'USA'); // if selected, addressType should be 'DOMESTIC' From c14ab94b0b3813bf4dab2d14f5141d2dc2f09edd Mon Sep 17 00:00:00 2001 From: Jarred Simon Date: Fri, 24 Nov 2023 15:55:06 -0600 Subject: [PATCH 4/6] #VYE-134 #comment updates made to change of Direct Deposit Schema, test currently failing --- dist/VYE-ADDRESS-CHANGE-schema.json | 1339 ++--------------- dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json | 50 + dist/definitions.json | 14 +- src/schemas/VYE-Address-Change/schema.js | 307 +--- .../VYE-Direct-Deposit-Change/schema.js | 29 + .../schemas/VYE-Address-Change/schema.spec.js | 105 +- .../VYE-Direct-Deposit-Change/schema.spec.js | 17 + 7 files changed, 300 insertions(+), 1561 deletions(-) create mode 100644 dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json create mode 100644 src/schemas/VYE-Direct-Deposit-Change/schema.js create mode 100644 test/schemas/VYE-Direct-Deposit-Change/schema.spec.js diff --git a/dist/VYE-ADDRESS-CHANGE-schema.json b/dist/VYE-ADDRESS-CHANGE-schema.json index 50a517c35..4fad6cdb1 100644 --- a/dist/VYE-ADDRESS-CHANGE-schema.json +++ b/dist/VYE-ADDRESS-CHANGE-schema.json @@ -1,888 +1,122 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Verify Your Enrollment Change of Address", + "title": "VERIFY YOUR ENROLLMENT CHANGE OF ADDRESS", "type": "object", - "additionalProperties": false, "definitions": { - "fullName": { + "address": { "type": "object", - "properties": { - "first": { - "type": "string", - "minLength": 1, - "maxLength": 30, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" - }, - "middle": { - "type": "string", - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$", - "maxLength": 20 - }, - "last": { - "type": "string", - "minLength": 1, - "maxLength": 30, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" - } - }, - "required": [ - "first", - "last" - ] - }, - "ssn": { - "type": "string", - "pattern": "^[0-9]{9}$" - }, - "domesticAddress": { - "type": "object", - "required": [ - "addressType", - "street", - "city", - "countryDropdown", - "state", - "postalCode" - ], - "properties": { - "addressType": { - "type": "string", - "enum": [ - "DOMESTIC" - ], - "default": "DOMESTIC" - }, - "street": { - "type": "string", - "minLength": 1, - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street2": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street3": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street4": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "city": { - "type": "string", - "maxLength": 30, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" - }, - "countryDropdown": { - "type": "string", - "maxLength": 50, - "default": "USA" - }, - "state": { - "type": "string", - "maxLength": 50, - "enum": [ - "AL", - "AK", - "AS", - "AZ", - "AR", - "AA", - "AE", - "AP", - "CA", - "CO", - "CT", - "DE", - "DC", - "FM", - "FL", - "GA", - "GU", - "HI", - "ID", - "IL", - "IN", - "IA", - "KS", - "KY", - "LA", - "ME", - "MH", - "MD", - "MA", - "MI", - "MN", - "MS", - "MO", - "MT", - "NE", - "NV", - "NH", - "NJ", - "NM", - "NY", - "NC", - "ND", - "MP", - "OH", - "OK", - "OR", - "PW", - "PA", - "PR", - "RI", - "SC", - "SD", - "TN", - "TX", - "UM", - "UT", - "VT", - "VI", - "VA", - "WA", - "WV", - "WI", - "WY" - ], - "enumNames": [ - "Alabama", - "Alaska", - "American Samoa", - "Arizona", - "Arkansas", - "Armed Forces Americas (AA)", - "Armed Forces Europe (AE)", - "Armed Forces Pacific (AP)", - "California", - "Colorado", - "Connecticut", - "Delaware", - "District Of Columbia", - "Federated States Of Micronesia", - "Florida", - "Georgia", - "Guam", - "Hawaii", - "Idaho", - "Illinois", - "Indiana", - "Iowa", - "Kansas", - "Kentucky", - "Louisiana", - "Maine", - "Marshall Islands", - "Maryland", - "Massachusetts", - "Michigan", - "Minnesota", - "Mississippi", - "Missouri", - "Montana", - "Nebraska", - "Nevada", - "New Hampshire", - "New Jersey", - "New Mexico", - "New York", - "North Carolina", - "North Dakota", - "Northern Mariana Islands", - "Ohio", - "Oklahoma", - "Oregon", - "Palau", - "Pennsylvania", - "Puerto Rico", - "Rhode Island", - "South Carolina", - "South Dakota", - "Tennessee", - "Texas", - "United States Minor Outlying Islands", - "Utah", - "Vermont", - "Virgin Islands", - "Virginia", - "Washington", - "West Virginia", - "Wisconsin", - "Wyoming" - ] - }, - "postalCode": { - "$ref": "#/definitions/postalCode" - } - }, - "additionalProperties": false - }, - "militaryAddress": { - "type": "object", - "required": [ - "addressType", - "street", - "city", - "countryDropdown", - "postOffice", - "postalType", - "postalCode" - ], - "properties": { - "addressType": { - "type": "string", - "enum": [ - "MILITARY" - ], - "default": "MILITARY" - }, - "street": { - "type": "string", - "minLength": 1, - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street2": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street3": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street4": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "city": { - "type": "string", - "maxLength": 30, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" - }, - "countryDropdown": { - "type": "string", - "maxLength": 50, - "enum": [ - "USA", - "Country Not In List", - "Afghanistan", - "Albania", - "Algeria", - "Angola", - "Anguilla", - "Antigua", - "Antigua and Barbuda", - "Argentina", - "Armenia", - "Australia", - "Austria", - "Azerbaijan", - "Azores", - "Bahamas", - "Bahrain", - "Bangladesh", - "Barbados", - "Barbuda", - "Belarus", - "Belgium", - "Belize", - "Benin", - "Bermuda", - "Bhutan", - "Bolivia", - "Bosnia-Herzegovina", - "Botswana", - "Brazil", - "Brunei", - "Bulgaria", - "Burkina Faso", - "Burma", - "Burundi", - "Cambodia", - "Cameroon", - "Canada", - "Cape Verde", - "Cayman Islands", - "Central African Republic", - "Chad", - "Chile", - "China", - "Colombia", - "Comoros", - "Congo, Democratic Republic of", - "Congo, People's Republic of", - "Costa Rica", - "Cote d'Ivoire", - "Croatia", - "Cuba", - "Cyprus", - "Czech Republic", - "Denmark", - "Djibouti", - "Dominica", - "Dominican Republic", - "Ecuador", - "Egypt", - "El Salvador", - "England", - "Equatorial Guinea", - "Eritrea", - "Estonia", - "Ethiopia", - "Fiji", - "Finland", - "France", - "French Guiana", - "Gabon", - "Gambia", - "Georgia", - "Germany", - "Ghana", - "Gibraltar", - "Great Britain", - "Great Britain and Gibraltar", - "Greece", - "Greenland", - "Grenada", - "Guadeloupe", - "Guatemala", - "Guinea", - "Guinea, Republic of Guinea", - "Guinea-Bissau", - "Guyana", - "Haiti", - "Honduras", - "Hong Kong", - "Hungary", - "Iceland", - "India", - "Indonesia", - "Iran", - "Iraq", - "Ireland", - "Israel (Jerusalem)", - "Israel (Tel Aviv)", - "Italy", - "Jamaica", - "Japan", - "Jordan", - "Kazakhstan", - "Kenya", - "Kosovo", - "Kuwait", - "Kyrgyzstan", - "Laos", - "Latvia", - "Lebanon", - "Leeward Islands", - "Lesotho", - "Liberia", - "Libya", - "Liechtenstein", - "Lithuania", - "Luxembourg", - "Macao", - "Macedonia", - "Madagascar", - "Malawi", - "Malaysia", - "Mali", - "Malta", - "Martinique", - "Mauritania", - "Mauritius", - "Mexico", - "Moldavia", - "Mongolia", - "Montenegro", - "Montserrat", - "Morocco", - "Mozambique", - "Namibia", - "Nepal", - "Netherlands", - "Netherlands Antilles", - "Nevis", - "New Caledonia", - "New Zealand", - "Nicaragua", - "Niger", - "Nigeria", - "North Korea", - "Northern Ireland", - "Norway", - "Oman", - "Pakistan", - "Panama", - "Papua New Guinea", - "Paraguay", - "Peru", - "Philippines", - "Philippines (restricted payments)", - "Poland", - "Portugal", - "Qatar", - "Republic of Yemen", - "Romania", - "Russia", - "Rwanda", - "Sao-Tome/Principe", - "Saudi Arabia", - "Scotland", - "Senegal", - "Serbia", - "Serbia/Montenegro", - "Seychelles", - "Sicily", - "Sierra Leone", - "Singapore", - "Slovakia", - "Slovenia", - "Somalia", - "South Africa", - "South Korea", - "Spain", - "Sri Lanka", - "St. Kitts", - "St. Lucia", - "St. Vincent", - "Sudan", - "Suriname", - "Swaziland", - "Sweden", - "Switzerland", - "Syria", - "Taiwan", - "Tajikistan", - "Tanzania", - "Thailand", - "Togo", - "Trinidad and Tobago", - "Tunisia", - "Turkey (Adana only)", - "Turkey (except Adana)", - "Turkmenistan", - "Uganda", - "Ukraine", - "United Arab Emirates", - "United Kingdom", - "Uruguay", - "Uzbekistan", - "Vanuatu", - "Venezuela", - "Vietnam", - "Wales", - "Western Samoa", - "Yemen Arab Republic", - "Zambia", - "Zimbabwe" - ] - }, - "postOffice": { - "type": "string", - "enum": [ - "APO", - "DPO", - "FPO" - ], - "enumNames": [ - "Ashore Post Office", - "Diplomatic Post Office", - "Fleet Post Office" - ] - }, - "postalType": { - "type": "string", - "enum": [ - "AA", - "AE", - "AP" - ], - "enumNames": [ - "Armed Forces Americas (except Canada)", - "Armed Forces Europe, Middle East, Canada & Africa", - "Armed Forces Pacific" - ] - }, - "postalCode": { - "$ref": "#/definitions/postalCode" - } - }, - "additionalProperties": false - }, - "internationalAddressDropDown": { - "type": "object", - "required": [ - "addressType", - "street", - "city", - "countryDropdown" - ], - "properties": { - "addressType": { - "type": "string", - "enum": [ - "INTERNATIONAL" - ], - "default": "INTERNATIONAL" - }, - "street": { - "type": "string", - "minLength": 1, - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street2": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street3": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street4": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "city": { - "type": "string", - "maxLength": 30, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" - }, - "countryDropdown": { - "type": "string", - "enum": [ - "Afghanistan", - "Albania", - "Algeria", - "Angola", - "Anguilla", - "Antigua", - "Antigua and Barbuda", - "Argentina", - "Armenia", - "Australia", - "Austria", - "Azerbaijan", - "Azores", - "Bahamas", - "Bahrain", - "Bangladesh", - "Barbados", - "Barbuda", - "Belarus", - "Belgium", - "Belize", - "Benin", - "Bermuda", - "Bhutan", - "Bolivia", - "Bosnia-Herzegovina", - "Botswana", - "Brazil", - "Brunei", - "Bulgaria", - "Burkina Faso", - "Burma", - "Burundi", - "Cambodia", - "Cameroon", - "Canada", - "Cape Verde", - "Cayman Islands", - "Central African Republic", - "Chad", - "Chile", - "China", - "Colombia", - "Comoros", - "Congo, Democratic Republic of", - "Congo, People's Republic of", - "Costa Rica", - "Cote d'Ivoire", - "Croatia", - "Cuba", - "Cyprus", - "Czech Republic", - "Denmark", - "Djibouti", - "Dominica", - "Dominican Republic", - "Ecuador", - "Egypt", - "El Salvador", - "England", - "Equatorial Guinea", - "Eritrea", - "Estonia", - "Ethiopia", - "Fiji", - "Finland", - "France", - "French Guiana", - "Gabon", - "Gambia", - "Georgia", - "Germany", - "Ghana", - "Gibraltar", - "Great Britain", - "Great Britain and Gibraltar", - "Greece", - "Greenland", - "Grenada", - "Guadeloupe", - "Guatemala", - "Guinea", - "Guinea, Republic of Guinea", - "Guinea-Bissau", - "Guyana", - "Haiti", - "Honduras", - "Hong Kong", - "Hungary", - "Iceland", - "India", - "Indonesia", - "Iran", - "Iraq", - "Ireland", - "Israel (Jerusalem)", - "Israel (Tel Aviv)", - "Italy", - "Jamaica", - "Japan", - "Jordan", - "Kazakhstan", - "Kenya", - "Kosovo", - "Kuwait", - "Kyrgyzstan", - "Laos", - "Latvia", - "Lebanon", - "Leeward Islands", - "Lesotho", - "Liberia", - "Libya", - "Liechtenstein", - "Lithuania", - "Luxembourg", - "Macao", - "Macedonia", - "Madagascar", - "Malawi", - "Malaysia", - "Mali", - "Malta", - "Martinique", - "Mauritania", - "Mauritius", - "Mexico", - "Moldavia", - "Mongolia", - "Montenegro", - "Montserrat", - "Morocco", - "Mozambique", - "Namibia", - "Nepal", - "Netherlands", - "Netherlands Antilles", - "Nevis", - "New Caledonia", - "New Zealand", - "Nicaragua", - "Niger", - "Nigeria", - "North Korea", - "Northern Ireland", - "Norway", - "Oman", - "Pakistan", - "Panama", - "Papua New Guinea", - "Paraguay", - "Peru", - "Philippines", - "Philippines (restricted payments)", - "Poland", - "Portugal", - "Qatar", - "Republic of Yemen", - "Romania", - "Russia", - "Rwanda", - "Sao-Tome/Principe", - "Saudi Arabia", - "Scotland", - "Senegal", - "Serbia", - "Serbia/Montenegro", - "Seychelles", - "Sicily", - "Sierra Leone", - "Singapore", - "Slovakia", - "Slovenia", - "Somalia", - "South Africa", - "South Korea", - "Spain", - "Sri Lanka", - "St. Kitts", - "St. Lucia", - "St. Vincent", - "Sudan", - "Suriname", - "Swaziland", - "Sweden", - "Switzerland", - "Syria", - "Taiwan", - "Tajikistan", - "Tanzania", - "Thailand", - "Togo", - "Trinidad and Tobago", - "Tunisia", - "Turkey (Adana only)", - "Turkey (except Adana)", - "Turkmenistan", - "Uganda", - "Ukraine", - "United Arab Emirates", - "United Kingdom", - "Uruguay", - "Uzbekistan", - "Vanuatu", - "Venezuela", - "Vietnam", - "Wales", - "Western Samoa", - "Yemen Arab Republic", - "Zambia", - "Zimbabwe" - ] - } - }, - "additionalProperties": false - }, - "internationalAddressText": { - "type": "object", - "required": [ - "addressType", - "street", - "city", - "countryDropdown", - "countryText" - ], - "properties": { - "addressType": { - "type": "string", - "enum": [ - "INTERNATIONAL" - ], - "default": "INTERNATIONAL" - }, - "street": { - "type": "string", - "minLength": 1, - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street2": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street3": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "street4": { - "type": "string", - "maxLength": 20, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$" - }, - "city": { - "type": "string", - "maxLength": 30, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" - }, - "countryDropdown": { - "type": "string", - "enum": [ - "Country Not In List" - ], - "default": "Country Not In List" - }, - "countryText": { - "type": "string", - "maxLength": 50, - "minLength": 1, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" - } - }, - "additionalProperties": false - }, - "postalCode": { - "type": "string", - "maxLength": 10, - "pattern": "^\\d{5}(?:[- ]?\\d{4})?$" - }, - "location": { - "type": "object", - "properties": {}, "oneOf": [ { - "required": [ - "countryDropdown", - "city", - "state" - ], "properties": { - "countryDropdown": { + "country": { "type": "string", "enum": [ - "USA" - ], - "default": "USA" + "CAN" + ] + }, + "state": { + "type": "string", + "enum": [ + "AB", + "BC", + "MB", + "NB", + "NF", + "NT", + "NV", + "NU", + "ON", + "PE", + "QC", + "SK", + "YT" + ] + }, + "postalCode": { + "type": "string", + "maxLength": 10 + } + } + }, + { + "properties": { + "country": { + "type": "string", + "enum": [ + "MEX" + ] + }, + "state": { + "type": "string", + "enum": [ + "aguascalientes", + "baja-california-norte", + "baja-california-sur", + "campeche", + "chiapas", + "chihuahua", + "coahuila", + "colima", + "distrito-federal", + "durango", + "guanajuato", + "guerrero", + "hidalgo", + "jalisco", + "mexico", + "michoacan", + "morelos", + "nayarit", + "nuevo-leon", + "oaxaca", + "puebla", + "queretaro", + "quintana-roo", + "san-luis-potosi", + "sinaloa", + "sonora", + "tabasco", + "tamaulipas", + "tlaxcala", + "veracruz", + "yucatan", + "zacatecas" + ] }, - "city": { + "postalCode": { + "type": "string", + "maxLength": 10 + } + } + }, + { + "properties": { + "country": { "type": "string", - "maxLength": 30, - "minLength": 1, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + "enum": [ + "USA" + ] }, "state": { "type": "string", - "maxLength": 50, "enum": [ "AL", "AK", + "AS", "AZ", "AR", + "AA", + "AE", + "AP", "CA", "CO", "CT", "DE", "DC", + "FM", "FL", "GA", + "GU", "HI", "ID", "IL", @@ -892,6 +126,7 @@ "KY", "LA", "ME", + "MH", "MD", "MA", "MI", @@ -907,10 +142,13 @@ "NY", "NC", "ND", + "MP", "OH", "OK", "OR", + "PW", "PA", + "PR", "RI", "SC", "SD", @@ -918,364 +156,79 @@ "TX", "UT", "VT", + "VI", "VA", "WA", "WV", "WI", "WY" - ], - "enumNames": [ - "Alabama", - "Alaska", - "Arizona", - "Arkansas", - "California", - "Colorado", - "Connecticut", - "Delaware", - "District Of Columbia", - "Florida", - "Georgia", - "Hawaii", - "Idaho", - "Illinois", - "Indiana", - "Iowa", - "Kansas", - "Kentucky", - "Louisiana", - "Maine", - "Maryland", - "Massachusetts", - "Michigan", - "Minnesota", - "Mississippi", - "Missouri", - "Montana", - "Nebraska", - "Nevada", - "New Hampshire", - "New Jersey", - "New Mexico", - "New York", - "North Carolina", - "North Dakota", - "Ohio", - "Oklahoma", - "Oregon", - "Pennsylvania", - "Rhode Island", - "South Carolina", - "South Dakota", - "Tennessee", - "Texas", - "Utah", - "Vermont", - "Virginia", - "Washington", - "West Virginia", - "Wisconsin", - "Wyoming" ] + }, + "postalCode": { + "type": "string", + "maxLength": 10 } - }, - "additionalProperties": false + } }, { - "required": [ - "countryDropdown", - "countryText" - ], "properties": { - "countryDropdown": { + "country": { + "not": { + "type": "string", + "enum": [ + "CAN", + "MEX", + "USA" + ] + } + }, + "state": { "type": "string", - "enum": [ - "Country Not In List" - ], - "default": "Country Not In List" + "maxLength": 51 }, - "countryText": { + "postalCode": { "type": "string", - "maxLength": 50, - "minLength": 1, - "pattern": "^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$" + "maxLength": 51 } - }, - "additionalProperties": false + } + } + ], + "properties": { + "street": { + "type": "string", + "minLength": 1, + "maxLength": 20 }, - { - "required": [ - "countryDropdown" - ], - "properties": { - "countryDropdown": { - "type": "string", - "enum": [ - "Afghanistan", - "Albania", - "Algeria", - "Angola", - "Anguilla", - "Antigua", - "Antigua and Barbuda", - "Argentina", - "Armenia", - "Australia", - "Austria", - "Azerbaijan", - "Azores", - "Bahamas", - "Bahrain", - "Bangladesh", - "Barbados", - "Barbuda", - "Belarus", - "Belgium", - "Belize", - "Benin", - "Bermuda", - "Bhutan", - "Bolivia", - "Bosnia-Herzegovina", - "Botswana", - "Brazil", - "Brunei", - "Bulgaria", - "Burkina Faso", - "Burma", - "Burundi", - "Cambodia", - "Cameroon", - "Canada", - "Cape Verde", - "Cayman Islands", - "Central African Republic", - "Chad", - "Chile", - "China", - "Colombia", - "Comoros", - "Congo, Democratic Republic of", - "Congo, People's Republic of", - "Costa Rica", - "Cote d'Ivoire", - "Croatia", - "Cuba", - "Cyprus", - "Czech Republic", - "Denmark", - "Djibouti", - "Dominica", - "Dominican Republic", - "Ecuador", - "Egypt", - "El Salvador", - "England", - "Equatorial Guinea", - "Eritrea", - "Estonia", - "Ethiopia", - "Fiji", - "Finland", - "France", - "French Guiana", - "Gabon", - "Gambia", - "Georgia", - "Germany", - "Ghana", - "Gibraltar", - "Great Britain", - "Great Britain and Gibraltar", - "Greece", - "Greenland", - "Grenada", - "Guadeloupe", - "Guatemala", - "Guinea", - "Guinea, Republic of Guinea", - "Guinea-Bissau", - "Guyana", - "Haiti", - "Honduras", - "Hong Kong", - "Hungary", - "Iceland", - "India", - "Indonesia", - "Iran", - "Iraq", - "Ireland", - "Israel (Jerusalem)", - "Israel (Tel Aviv)", - "Italy", - "Jamaica", - "Japan", - "Jordan", - "Kazakhstan", - "Kenya", - "Kosovo", - "Kuwait", - "Kyrgyzstan", - "Laos", - "Latvia", - "Lebanon", - "Leeward Islands", - "Lesotho", - "Liberia", - "Libya", - "Liechtenstein", - "Lithuania", - "Luxembourg", - "Macao", - "Macedonia", - "Madagascar", - "Malawi", - "Malaysia", - "Mali", - "Malta", - "Martinique", - "Mauritania", - "Mauritius", - "Mexico", - "Moldavia", - "Mongolia", - "Montenegro", - "Montserrat", - "Morocco", - "Mozambique", - "Namibia", - "Nepal", - "Netherlands", - "Netherlands Antilles", - "Nevis", - "New Caledonia", - "New Zealand", - "Nicaragua", - "Niger", - "Nigeria", - "North Korea", - "Northern Ireland", - "Norway", - "Oman", - "Pakistan", - "Panama", - "Papua New Guinea", - "Paraguay", - "Peru", - "Philippines", - "Philippines (restricted payments)", - "Poland", - "Portugal", - "Qatar", - "Republic of Yemen", - "Romania", - "Russia", - "Rwanda", - "Sao-Tome/Principe", - "Saudi Arabia", - "Scotland", - "Senegal", - "Serbia", - "Serbia/Montenegro", - "Seychelles", - "Sicily", - "Sierra Leone", - "Singapore", - "Slovakia", - "Slovenia", - "Somalia", - "South Africa", - "South Korea", - "Spain", - "Sri Lanka", - "St. Kitts", - "St. Lucia", - "St. Vincent", - "Sudan", - "Suriname", - "Swaziland", - "Sweden", - "Switzerland", - "Syria", - "Taiwan", - "Tajikistan", - "Tanzania", - "Thailand", - "Togo", - "Trinidad and Tobago", - "Tunisia", - "Turkey (Adana only)", - "Turkey (except Adana)", - "Turkmenistan", - "Uganda", - "Ukraine", - "United Arab Emirates", - "United Kingdom", - "Uruguay", - "Uzbekistan", - "Vanuatu", - "Venezuela", - "Vietnam", - "Wales", - "Western Samoa", - "Yemen Arab Republic", - "Zambia", - "Zimbabwe" - ] - } - }, - "additionalProperties": false + "street2": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "street3": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "street4": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "city": { + "type": "string", + "minLength": 1, + "maxLength": 51 } - ] - }, - "vaFileNumber": { - "type": "string", - "pattern": "^[cC]{0,1}\\d{7,9}$" + } } }, + "additionalProperties": false, "properties": { "veteranAddress": { - "type": "object", - "oneOf": [ - { - "$ref": "#/definitions/domesticAddress" - }, - { - "$ref": "#/definitions/militaryAddress" - }, - { - "$ref": "#/definitions/internationalAddressDropDown" - }, - { - "$ref": "#/definitions/internationalAddressText" - } - ] - }, - "veteranSocialSecurityNumber": { - "$ref": "#/definitions/ssn" - }, - "veteranFullName": { - "$ref": "#/definitions/fullName" - }, - "vaFileNumber": { - "$ref": "#/definitions/vaFileNumber" + "$ref": "#/definitions/address" } }, "required": [ - "veteranFullName", "veteranAddress" - ], - "anyOf": [ - { - "required": [ - "vaFileNumber" - ] - }, - { - "required": [ - "veteranSocialSecurityNumber" - ] - } ] } diff --git a/dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json b/dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json new file mode 100644 index 000000000..a01c5ebcd --- /dev/null +++ b/dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json @@ -0,0 +1,50 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "VERIFY YOUR ENROLLMENT CHANGE OF DIRECT DEPOSIT", + "type": "object", + "additionalProperties": false, + "definitions": { + "bankAccount": { + "type": "object", + "properties": { + "accountType": { + "type": "string", + "enum": [ + "checking", + "savings" + ] + }, + "routingNumber": { + "type": "string", + "pattern": "^\\d{9}$" + }, + "accountNumber": { + "type": "string" + } + } + }, + "usaPhone": { + "type": "string", + "pattern": "^\\d{10}$" + } + }, + "properties": { + "bankAccount": { + "$ref": "#/definitions/bankAccount" + }, + "checkDigit": { + "type": "string" + }, + "bankName": { + "type": "string" + }, + "bankPhone": { + "$ref": "#/definitions/usaPhone" + } + }, + "required": [ + "bankName", + "bankAccount", + "bankPhone" + ] +} diff --git a/dist/definitions.json b/dist/definitions.json index 010131f93..97be336cb 100644 --- a/dist/definitions.json +++ b/dist/definitions.json @@ -263,12 +263,22 @@ "street": { "type": "string", "minLength": 1, - "maxLength": 50 + "maxLength": 20 }, "street2": { "type": "string", "minLength": 1, - "maxLength": 50 + "maxLength": 20 + }, + "street3": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "street4": { + "type": "string", + "minLength": 1, + "maxLength": 20 }, "city": { "type": "string", diff --git a/src/schemas/VYE-Address-Change/schema.js b/src/schemas/VYE-Address-Change/schema.js index 67130defe..90019cb70 100644 --- a/src/schemas/VYE-Address-Change/schema.js +++ b/src/schemas/VYE-Address-Change/schema.js @@ -1,272 +1,49 @@ import _ from 'lodash'; -import schemaHelpers from '../../common/schema-helpers'; -import originalDefinitions from '../../common/definitions'; -import constants from '../../common/constants'; +import definitions from '../../common/definitions'; -const { states: constStates, states50AndDC, pciuCountries } = constants; - -// if any of these countries are selected, addressType should be 'INTERNATIONAL' -const nonUSACountries = pciuCountries.filter(country => country !== 'USA'); -const countryUSA = pciuCountries.find(country => country === 'USA'); // if selected, addressType should be 'DOMESTIC' -const countryNotInList = 'Country Not In List'; // if selected, addressType should be 'INTERNATIONAL' - -const states = constStates.USA.concat([ - { value: 'UM', label: 'United States Minor Outlying Islands' }, -]).sort((stateA, stateB) => stateA.label.localeCompare(stateB.label)); - -const textRegex = '^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*0-9]+$'; -const textAndNumbersRegex = '^(?!\\s)(?!.*?\\s{2,})[^<>%$#@!^&*]+$'; - -let definitions = _.cloneDeep(originalDefinitions); -definitions = _.pick(definitions, 'fullName', 'ssn'); - -definitions.fullName.properties.first.pattern = textRegex; -definitions.fullName.properties.last.pattern = textRegex; -definitions.fullName.properties.middle.pattern = textRegex; -definitions.fullName.properties.first.maxLength = 30; -definitions.fullName.properties.last.maxLength = 30; -definitions.fullName.properties.middle.maxLength = 20; -delete definitions.fullName.properties.suffix; - -const commonAddressFields = { - required: ['addressType', 'street', 'city', 'countryDropdown'], +const schema = { + $schema: 'http://json-schema.org/draft-04/schema#', + title: 'VERIFY YOUR ENROLLMENT CHANGE OF ADDRESS', + type: 'object', + definitions:_.merge( + _.set( + _.pick(definitions,['address']), + 'address.properties', + { + "street": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "street2": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "street3": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "street4": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "city": { + "type": "string", + "minLength": 1, + "maxLength": 51 + } + } + ) + ), + additionalProperties: false, properties: { - addressType: { - type: 'string', - enum: ['DOMESTIC', 'MILITARY', 'INTERNATIONAL'], - enumNames: ['Domestic', 'Military', 'International'], - }, - street: { - type: 'string', - minLength: 1, - maxLength: 20, - pattern: textAndNumbersRegex, - }, - street2: { - type: 'string', - maxLength: 20, - pattern: textAndNumbersRegex, - }, - street3: { - type: 'string', - maxLength: 20, - pattern: textAndNumbersRegex, - }, - street4: { - type: 'string', - maxLength: 20, - pattern: textAndNumbersRegex, - }, - city: { - type: 'string', - maxLength: 30, - pattern: textRegex, - }, - countryDropdown: { - type: 'string', - maxLength: 50, - enum: [countryUSA, countryNotInList].concat(nonUSACountries), + veteranAddress: { + $ref: '#/definitions/address', }, }, + required: ['veteranAddress'], }; - -const addressDefs = [ - { $ref: '#/definitions/domesticAddress' }, - { $ref: '#/definitions/militaryAddress' }, - { $ref: '#/definitions/internationalAddressDropDown' }, - { $ref: '#/definitions/internationalAddressText' }, -]; - -const schema = { - $schema: 'http://json-schema.org/draft-04/schema#', - title: 'Verify Your Enrollment Change of Address', - type: 'object', - additionalProperties: false, - definitions: _.merge(definitions, { - domesticAddress: { - type: 'object', - required: [...commonAddressFields.required, 'state', 'postalCode'], - properties: { - ...commonAddressFields.properties, - addressType: { - type: 'string', - enum: ['DOMESTIC'], - default: 'DOMESTIC', - }, - state: { - type: 'string', - maxLength: 50, - enum: states.map(state => state.value), - enumNames: states.map(state => state.label), - }, - postalCode: { - $ref: '#/definitions/postalCode', - }, - countryDropdown: { - type: 'string', - maxLength: 50, - default: countryUSA, - }, - }, - additionalProperties: false, - }, - militaryAddress: { - type: 'object', - required: [...commonAddressFields.required, 'postOffice', 'postalType', 'postalCode'], - properties: { - ...commonAddressFields.properties, - addressType: { - type: 'string', - enum: ['MILITARY'], - default: 'MILITARY', - }, - postOffice: { - type: 'string', - enum: ['APO', 'DPO', 'FPO'], - enumNames: ['Ashore Post Office', 'Diplomatic Post Office', 'Fleet Post Office'], - }, - postalType: { - type: 'string', - enum: ['AA', 'AE', 'AP'], - enumNames: [ - 'Armed Forces Americas (except Canada)', - 'Armed Forces Europe, Middle East, Canada & Africa', - 'Armed Forces Pacific', - ], - }, - postalCode: { - $ref: '#/definitions/postalCode', - }, - }, - additionalProperties: false, - }, - internationalAddressDropDown: { - type: 'object', - required: [...commonAddressFields.required], - properties: { - ...commonAddressFields.properties, - addressType: { - type: 'string', - enum: ['INTERNATIONAL'], - default: 'INTERNATIONAL', - }, - countryDropdown: { - type: 'string', - enum: nonUSACountries, - }, - }, - additionalProperties: false, - }, - internationalAddressText: { - type: 'object', - required: [...commonAddressFields.required, 'countryText'], - properties: { - ...commonAddressFields.properties, - addressType: { - type: 'string', - enum: ['INTERNATIONAL'], - default: 'INTERNATIONAL', - }, - countryDropdown: { - type: 'string', - enum: [countryNotInList], - default: countryNotInList, - }, - countryText: { - type: 'string', - maxLength: 50, - minLength: 1, - pattern: textRegex, - }, - }, - additionalProperties: false, - }, - postalCode: { - type: 'string', - maxLength: 10, - pattern: '^\\d{5}(?:[- ]?\\d{4})?$', - }, - location: { - type: 'object', - properties: {}, - oneOf: [ - { - required: ['countryDropdown', 'city', 'state'], - properties: { - countryDropdown: { - type: 'string', - enum: [countryUSA], - default: countryUSA, - }, - city: { - type: 'string', - maxLength: 30, - minLength: 1, - pattern: textRegex, - }, - state: { - type: 'string', - maxLength: 50, - enum: states50AndDC.map(state => state.value), - enumNames: states50AndDC.map(state => state.label), - }, - }, - additionalProperties: false, - }, - { - required: ['countryDropdown', 'countryText'], - properties: { - countryDropdown: { - type: 'string', - enum: [countryNotInList], - default: countryNotInList, - }, - countryText: { - type: 'string', - maxLength: 50, - minLength: 1, - pattern: textRegex, - }, - }, - additionalProperties: false, - }, - { - required: ['countryDropdown'], - properties: { - countryDropdown: { - type: 'string', - enum: nonUSACountries, - }, - }, - additionalProperties: false, - }, - ], - }, - }), - properties: { - veteranAddress: { - type: 'object', - oneOf: addressDefs, - }, - veteranSocialSecurityNumber: { $ref: '#/definitions/ssn' }, - }, - required: ['veteranFullName', 'veteranAddress'], - anyOf: [ - { - required: ['vaFileNumber'], - }, - { - required: ['veteranSocialSecurityNumber'], - }, - ], -}; - -[ - - ['fullName', 'veteranFullName'], - ['vaFileNumber'], -].forEach(args => { - schemaHelpers.addDefinitionToSchema(schema, ...args); -}); - export default schema; diff --git a/src/schemas/VYE-Direct-Deposit-Change/schema.js b/src/schemas/VYE-Direct-Deposit-Change/schema.js new file mode 100644 index 000000000..ad55c957e --- /dev/null +++ b/src/schemas/VYE-Direct-Deposit-Change/schema.js @@ -0,0 +1,29 @@ +import _ from 'lodash'; +import definitions from '../../common/definitions'; + + +const schema = { + $schema: 'http://json-schema.org/draft-04/schema#', + title: 'VERIFY YOUR ENROLLMENT CHANGE OF DIRECT DEPOSIT', + type: 'object', + additionalProperties: false, + definitions:_.merge( + _.pick(definitions,['bankAccount','usaPhone']) + ), + properties: { + bankAccount: { + $ref: '#/definitions/bankAccount', + }, + checkDigit: { + type: 'string', + }, + bankName:{ + type:'string' + }, + bankPhone:{ + $ref: '#/definitions/usaPhone', + }, + }, + required: ['bankName', 'bankAccount', 'bankPhone',], +}; +export default schema; diff --git a/test/schemas/VYE-Address-Change/schema.spec.js b/test/schemas/VYE-Address-Change/schema.spec.js index aaaccaf44..ca9374739 100644 --- a/test/schemas/VYE-Address-Change/schema.spec.js +++ b/test/schemas/VYE-Address-Change/schema.spec.js @@ -1,108 +1,11 @@ -import _ from 'lodash'; -import { expect } from 'chai'; import SchemaTestHelper from '../../support/schema-test-helper'; import schemas from '../../../dist/schemas'; import SharedTests from '../../support/shared-tests'; const schema = schemas['VYE-ADDRESS-CHANGE']; -const schemaWithoutRequired = _.cloneDeep(schema); -delete schemaWithoutRequired.required; -delete schemaWithoutRequired.anyOf; +const schemaTestHelper = new SchemaTestHelper(schema); +const sharedTests = new SharedTests(schemaTestHelper) -const schemaTestHelper = new SchemaTestHelper(schemaWithoutRequired); -const sharedTests = new SharedTests(schemaTestHelper); - -describe('21-686C schema', () => { - it('should have the right required fields', () => { - expect(schema.required).to.deep.equal([ - 'veteranFullName', - 'veteranAddress', - ]); - }); - - sharedTests.runTest('fullName', ['veteranFullName']); - sharedTests.runTest('vaFileNumber', ['vaFileNumber']); - sharedTests.runTest('ssn', ['veteranSocialSecurityNumber']); - - schemaTestHelper.testValidAndInvalid('veteranAddress', { - valid: [ - { - addressType: 'DOMESTIC', - street: '123 main st.', - city: 'anywhere', - countryDropdown: 'USA', - state: 'KY', - postalCode: '55555', - }, - { - addressType: 'MILITARY', - street: '123 main st.', - city: 'anywhere', - countryDropdown: 'USA', - postOffice: 'APO', - postalType: 'AA', - postalCode: '55555', - }, - { - addressType: 'INTERNATIONAL', - street: '123 main st.', - city: 'anywhere', - countryDropdown: 'Canada', - }, - { - addressType: 'INTERNATIONAL', - street: '123 main st.', - city: 'anywhere', - countryDropdown: 'Country Not In List', - countryText: 'Independent Nation of Myself', - }, - ], - invalid: [ - // INTERNATIONAL with country of 'USA' - { - addressType: 'INTERNATIONAL', - street: '123 main st.', - city: 'anywhere', - countryDropdown: 'USA', - }, - - // INTERNATIONAL (Country Not In List) with state and postalCode - { - addressType: 'INTERNATIONAL', - street: '123 main st.', - city: 'anywhere', - countryDropdown: 'Country Not In List', - state: 'KY', - postalCode: '55555', - }, - - // INTERNATIONAL with state and postalCode - { - addressType: 'INTERNATIONAL', - street: '123 main st.', - city: 'anywhere', - state: 'KY', - countryDropdown: 'Bangladesh', - }, - - // INTERNATIONAL with selected country (allowed) and countryText (not allowed) - { - addressType: 'INTERNATIONAL', - street: '123 main st.', - city: 'anywhere', - countryDropdown: 'Canada', - countryText: 'Independent Nation of Myself', - }, - - // consecutive spaces present - { - addressType: 'DOMESTIC', - street: '123 main st.', - city: 'any where', - countryDropdown: 'USA', - state: 'KY', - postalCode: '55555', - }, - ], - }); +describe('VYE address change', () => { + sharedTests.runTest('address', ['veteranAddress']); }); diff --git a/test/schemas/VYE-Direct-Deposit-Change/schema.spec.js b/test/schemas/VYE-Direct-Deposit-Change/schema.spec.js new file mode 100644 index 000000000..2c4b19477 --- /dev/null +++ b/test/schemas/VYE-Direct-Deposit-Change/schema.spec.js @@ -0,0 +1,17 @@ +import SchemaTestHelper from '../../support/schema-test-helper'; +import schemas from '../../../dist/schemas'; +import SharedTests from '../../support/shared-tests'; + +const schema = schemas['VYE-DIRECT-DEPOSIT-CHANGE']; + +let schemaTestHelper = new SchemaTestHelper(schema); +let sharedTests = new SharedTests(schemaTestHelper); + +describe('VYE direct deposit change', () => { + [ + 'bankAccount', + 'usaPhone' + ].forEach((test) => { + sharedTests.runTest(test); + }); +}); From e89a2b6336b6942c9dd1225dcc00fc0b9f50b7e5 Mon Sep 17 00:00:00 2001 From: Jarred Simon Date: Fri, 24 Nov 2023 18:10:35 -0600 Subject: [PATCH 5/6] #VYE-134 #comment schema for direct deposit is complete with tests passing --- dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json | 6 ++--- .../VYE-Direct-Deposit-Change/schema.js | 23 +++++++++---------- .../VYE-Direct-Deposit-Change/schema.spec.js | 21 +++++++++++------ 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json b/dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json index a01c5ebcd..13a10bb44 100644 --- a/dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json +++ b/dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json @@ -29,15 +29,15 @@ } }, "properties": { - "bankAccount": { - "$ref": "#/definitions/bankAccount" - }, "checkDigit": { "type": "string" }, "bankName": { "type": "string" }, + "bankAccount": { + "$ref": "#/definitions/bankAccount" + }, "bankPhone": { "$ref": "#/definitions/usaPhone" } diff --git a/src/schemas/VYE-Direct-Deposit-Change/schema.js b/src/schemas/VYE-Direct-Deposit-Change/schema.js index ad55c957e..8b79054ec 100644 --- a/src/schemas/VYE-Direct-Deposit-Change/schema.js +++ b/src/schemas/VYE-Direct-Deposit-Change/schema.js @@ -1,29 +1,28 @@ -import _ from 'lodash'; -import definitions from '../../common/definitions'; - +import schemaHelpers from '../../common/schema-helpers'; const schema = { $schema: 'http://json-schema.org/draft-04/schema#', title: 'VERIFY YOUR ENROLLMENT CHANGE OF DIRECT DEPOSIT', type: 'object', additionalProperties: false, - definitions:_.merge( - _.pick(definitions,['bankAccount','usaPhone']) - ), + definitions:{}, properties: { - bankAccount: { - $ref: '#/definitions/bankAccount', - }, + checkDigit: { type: 'string', }, bankName:{ type:'string' }, - bankPhone:{ - $ref: '#/definitions/usaPhone', - }, }, required: ['bankName', 'bankAccount', 'bankPhone',], }; + +[ + ['bankAccount'], + ['usaPhone', 'bankPhone'], +].forEach(args => { + schemaHelpers.addDefinitionToSchema(schema, ...args); +}); + export default schema; diff --git a/test/schemas/VYE-Direct-Deposit-Change/schema.spec.js b/test/schemas/VYE-Direct-Deposit-Change/schema.spec.js index 2c4b19477..d31793263 100644 --- a/test/schemas/VYE-Direct-Deposit-Change/schema.spec.js +++ b/test/schemas/VYE-Direct-Deposit-Change/schema.spec.js @@ -4,14 +4,21 @@ import SharedTests from '../../support/shared-tests'; const schema = schemas['VYE-DIRECT-DEPOSIT-CHANGE']; -let schemaTestHelper = new SchemaTestHelper(schema); -let sharedTests = new SharedTests(schemaTestHelper); +const schemaTestHelper = new SchemaTestHelper(schema,{ + bankName: "Test Name", + bankAccount: { accountType: 'checking', routingNumber: '123123123', accountNumber: '1234' }, + bankPhone: '1231231231', +}); + +const sharedTests = new SharedTests(schemaTestHelper); + describe('VYE direct deposit change', () => { - [ - 'bankAccount', - 'usaPhone' - ].forEach((test) => { - sharedTests.runTest(test); + sharedTests.runTest('bankAccount', ['bankAccount']); + sharedTests.runTest('usaPhone', ['bankPhone']) + + schemaTestHelper.testValidAndInvalid('bankName', { + valid: ['Test Name'], + invalid: [234], }); }); From 0627443e265e60429785d9c015c400931738c4d9 Mon Sep 17 00:00:00 2001 From: Jarred Simon Date: Wed, 29 Nov 2023 11:14:58 -0600 Subject: [PATCH 6/6] #VYE-134 #comment removed streetAddress4 from VYE-ADRRESS-CHANGE schema --- dist/VYE-ADDRESS-CHANGE-schema.json | 5 ----- dist/definitions.json | 5 ----- src/schemas/VYE-Address-Change/schema.js | 5 ----- 3 files changed, 15 deletions(-) diff --git a/dist/VYE-ADDRESS-CHANGE-schema.json b/dist/VYE-ADDRESS-CHANGE-schema.json index 4fad6cdb1..ae528aa6e 100644 --- a/dist/VYE-ADDRESS-CHANGE-schema.json +++ b/dist/VYE-ADDRESS-CHANGE-schema.json @@ -209,11 +209,6 @@ "minLength": 1, "maxLength": 20 }, - "street4": { - "type": "string", - "minLength": 1, - "maxLength": 20 - }, "city": { "type": "string", "minLength": 1, diff --git a/dist/definitions.json b/dist/definitions.json index 97be336cb..cbfe342bd 100644 --- a/dist/definitions.json +++ b/dist/definitions.json @@ -275,11 +275,6 @@ "minLength": 1, "maxLength": 20 }, - "street4": { - "type": "string", - "minLength": 1, - "maxLength": 20 - }, "city": { "type": "string", "minLength": 1, diff --git a/src/schemas/VYE-Address-Change/schema.js b/src/schemas/VYE-Address-Change/schema.js index 90019cb70..226a13a4a 100644 --- a/src/schemas/VYE-Address-Change/schema.js +++ b/src/schemas/VYE-Address-Change/schema.js @@ -25,11 +25,6 @@ const schema = { "minLength": 1, "maxLength": 20 }, - "street4": { - "type": "string", - "minLength": 1, - "maxLength": 20 - }, "city": { "type": "string", "minLength": 1,