diff --git a/dist/VYE-ADDRESS-CHANGE-schema.json b/dist/VYE-ADDRESS-CHANGE-schema.json new file mode 100644 index 000000000..ae528aa6e --- /dev/null +++ b/dist/VYE-ADDRESS-CHANGE-schema.json @@ -0,0 +1,229 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "VERIFY YOUR ENROLLMENT CHANGE OF ADDRESS", + "type": "object", + "definitions": { + "address": { + "type": "object", + "oneOf": [ + { + "properties": { + "country": { + "type": "string", + "enum": [ + "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" + ] + }, + "postalCode": { + "type": "string", + "maxLength": 10 + } + } + }, + { + "properties": { + "country": { + "type": "string", + "enum": [ + "USA" + ] + }, + "state": { + "type": "string", + "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", + "UT", + "VT", + "VI", + "VA", + "WA", + "WV", + "WI", + "WY" + ] + }, + "postalCode": { + "type": "string", + "maxLength": 10 + } + } + }, + { + "properties": { + "country": { + "not": { + "type": "string", + "enum": [ + "CAN", + "MEX", + "USA" + ] + } + }, + "state": { + "type": "string", + "maxLength": 51 + }, + "postalCode": { + "type": "string", + "maxLength": 51 + } + } + } + ], + "properties": { + "street": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "street2": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "street3": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "city": { + "type": "string", + "minLength": 1, + "maxLength": 51 + } + } + } + }, + "additionalProperties": false, + "properties": { + "veteranAddress": { + "$ref": "#/definitions/address" + } + }, + "required": [ + "veteranAddress" + ] +} diff --git a/dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json b/dist/VYE-DIRECT-DEPOSIT-CHANGE-schema.json new file mode 100644 index 000000000..13a10bb44 --- /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": { + "checkDigit": { + "type": "string" + }, + "bankName": { + "type": "string" + }, + "bankAccount": { + "$ref": "#/definitions/bankAccount" + }, + "bankPhone": { + "$ref": "#/definitions/usaPhone" + } + }, + "required": [ + "bankName", + "bankAccount", + "bankPhone" + ] +} diff --git a/dist/definitions.json b/dist/definitions.json index 254701109..3def172f5 100644 --- a/dist/definitions.json +++ b/dist/definitions.json @@ -263,12 +263,17 @@ "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 }, "city": { "type": "string", diff --git a/src/schemas/VYE-Address-Change/schema.js b/src/schemas/VYE-Address-Change/schema.js new file mode 100644 index 000000000..226a13a4a --- /dev/null +++ b/src/schemas/VYE-Address-Change/schema.js @@ -0,0 +1,44 @@ +import _ from 'lodash'; +import definitions from '../../common/definitions'; + +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 + }, + "city": { + "type": "string", + "minLength": 1, + "maxLength": 51 + } + } + ) + ), + additionalProperties: false, + properties: { + veteranAddress: { + $ref: '#/definitions/address', + }, + }, + required: ['veteranAddress'], +}; +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..8b79054ec --- /dev/null +++ b/src/schemas/VYE-Direct-Deposit-Change/schema.js @@ -0,0 +1,28 @@ +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:{}, + properties: { + + checkDigit: { + type: 'string', + }, + bankName:{ + type:'string' + }, + }, + required: ['bankName', 'bankAccount', 'bankPhone',], +}; + +[ + ['bankAccount'], + ['usaPhone', 'bankPhone'], +].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..ca9374739 --- /dev/null +++ b/test/schemas/VYE-Address-Change/schema.spec.js @@ -0,0 +1,11 @@ +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 schemaTestHelper = new SchemaTestHelper(schema); +const sharedTests = new SharedTests(schemaTestHelper) + +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..d31793263 --- /dev/null +++ b/test/schemas/VYE-Direct-Deposit-Change/schema.spec.js @@ -0,0 +1,24 @@ +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']; + +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', () => { + sharedTests.runTest('bankAccount', ['bankAccount']); + sharedTests.runTest('usaPhone', ['bankPhone']) + + schemaTestHelper.testValidAndInvalid('bankName', { + valid: ['Test Name'], + invalid: [234], + }); +});