= this.minDate
+ }
+
return date > this.minDate
}
diff --git a/src/validators/datecontrol.test.js b/src/validators/datecontrol.test.js
index d3f77d677..52b225d62 100644
--- a/src/validators/datecontrol.test.js
+++ b/src/validators/datecontrol.test.js
@@ -65,6 +65,16 @@ describe('date control validator', function() {
},
expected: false
},
+ {
+ data: {
+ month: '1',
+ day: '1',
+ year: '2005',
+ maxDate: new Date('1/1/2005'),
+ maxDateEqualTo: true
+ },
+ expected: true
+ },
{
data: {
month: '1',
@@ -148,6 +158,17 @@ describe('date control validator', function() {
hideDay: true
},
expected: false
+ },
+ {
+ data: {
+ month: '1',
+ day: '1',
+ year: '2004',
+ minDate: new Date('1/1/2004'),
+ minDateEqualTo: true,
+ hideDay: true
+ },
+ expected: true
}
]
diff --git a/src/validators/helpers.js b/src/validators/helpers.js
index 97008c394..7eecbc827 100644
--- a/src/validators/helpers.js
+++ b/src/validators/helpers.js
@@ -18,7 +18,7 @@ export const validCurrency = obj => {
if (!obj || !obj.value || isNaN(obj.value)) {
return false
}
- return true
+ return +obj.value < 2147483648
}
/**
diff --git a/src/validators/helpers.test.js b/src/validators/helpers.test.js
index 893e5ada8..832463e0a 100644
--- a/src/validators/helpers.test.js
+++ b/src/validators/helpers.test.js
@@ -79,6 +79,12 @@ describe('Helpers for validators', function() {
value: 'f'
},
expected: false
+ },
+ {
+ Field: {
+ value: '2147483648'
+ },
+ expected: false
}
]
diff --git a/src/validators/people.test.js b/src/validators/people.test.js
index 3372bc259..b9c347241 100644
--- a/src/validators/people.test.js
+++ b/src/validators/people.test.js
@@ -51,13 +51,7 @@ describe('People validator', function() {
year: '2009',
date: new Date('1/1/2009')
},
- to: {
- month: '1',
- day: '1',
- year: currentYear,
- date: new Date(`1/1/${currentYear}`)
- },
- present: false
+ present: true
},
Rank: {
value: 'Some rank'
diff --git a/src/validators/relatives.js b/src/validators/relatives.js
index 600be4989..9244fa455 100644
--- a/src/validators/relatives.js
+++ b/src/validators/relatives.js
@@ -18,8 +18,29 @@ export default class RelativesValidator {
})
}
+ validMinimumRelations() {
+ const requiredRelations = ['Father', 'Mother']
+
+ if ((this.list.branch || {}).value === 'No') {
+ if (this.list.items && this.list.items.length > 0) {
+ let relations = []
+ for (const item of this.list.items) {
+ if (!item || !item.Item || !item.Item.Relation) {
+ continue
+ }
+ relations.push(item.Item.Relation.value)
+ }
+ if (relations.length > 0) {
+ return requiredRelations.every(r => relations.includes(r))
+ }
+ }
+ return false
+ }
+ return true
+ }
+
isValid() {
- return this.validItems()
+ return this.validItems() && this.validMinimumRelations()
}
}
@@ -159,7 +180,12 @@ export class RelativeValidator {
validAliases() {
const items = this.aliases.items || []
- const nonImmediateFamily = ['Fosterparent', 'Father-in-law', 'Mother-in-law', 'Guardian']
+ const nonImmediateFamily = [
+ 'Fosterparent',
+ 'Father-in-law',
+ 'Mother-in-law',
+ 'Guardian'
+ ]
if (nonImmediateFamily.includes(this.relation)) {
return true
diff --git a/src/validators/relatives.test.js b/src/validators/relatives.test.js
index 68998a7bc..40ff1f347 100644
--- a/src/validators/relatives.test.js
+++ b/src/validators/relatives.test.js
@@ -1635,29 +1635,103 @@ describe('Relatives validation', function() {
{
data: {
List: {
- branch: { value: 'Nope' },
+ branch: { value: 'No' },
items: [
{
Item: {
Relation: {
value: 'Mother'
+ },
+ Name: {
+ first: 'Foo',
+ firstInitialOnly: false,
+ middle: 'J',
+ middleInitialOnly: true,
+ noMiddleName: false,
+ last: 'Bar',
+ lastInitialOnly: false,
+ suffix: 'Jr'
+ },
+ Birthdate: {
+ day: '1',
+ month: '1',
+ year: '2016',
+ date: new Date('1/1/2016')
+ },
+ Birthplace: {
+ city: 'Arlington',
+ state: 'VA',
+ country: { value: ['United States'] },
+ layout: Location.BIRTHPLACE_WITHOUT_COUNTY
+ },
+ Citizenship: {
+ value: ['United States']
+ },
+ MaidenName: {
+ first: 'Foo',
+ firstInitialOnly: false,
+ middle: 'J',
+ middleInitialOnly: true,
+ noMiddleName: false,
+ last: 'Bar',
+ lastInitialOnly: false,
+ suffix: 'Jr'
+ },
+ Aliases: {
+ items: [
+ {
+ Item: {
+ Has: {
+ value: 'Yes'
+ },
+ Name: {
+ first: 'Foo',
+ firstInitialOnly: false,
+ middle: 'J',
+ middleInitialOnly: true,
+ noMiddleName: false,
+ last: 'Bar',
+ lastInitialOnly: false,
+ suffix: 'Jr'
+ },
+ MaidenName: { value: 'No' },
+ Dates: {
+ from: {
+ month: '1',
+ day: '1',
+ year: '2010',
+ date: new Date('1/1/2010')
+ },
+ to: {
+ month: '1',
+ day: '1',
+ year: '2012',
+ date: new Date('1/1/2012')
+ },
+ present: false
+ },
+ Reason: {
+ value: 'The reason'
+ }
+ }
+ }
+ ]
+ },
+ IsDeceased: { value: 'No' },
+ Address: {
+ country: { value: 'United States' },
+ street: '1234 Some Rd',
+ city: 'Arlington',
+ state: 'VA',
+ zipcode: '22202',
+ layout: Location.ADDRESS
}
}
- }
- ]
- }
- },
- expected: false
- },
- {
- data: {
- List: {
- branch: { value: 'No' },
- items: [
+ },
{
Item: {
Relation: {
- value: 'Mother'
+ value: 'Father'
},
Name: {
first: 'Foo',
@@ -1756,4 +1830,73 @@ describe('Relatives validation', function() {
expect(new RelativesValidator(test.data).isValid()).toBe(test.expected)
})
})
+
+ it('validates that a mother and father have been provided', () => {
+ const tests = [
+ {
+ data: {
+ List: {
+ branch: { value: 'No' },
+ items: [
+ {
+ Item: {
+ Relation: {
+ value: 'Mother'
+ }
+ }
+ }
+ ]
+ }
+ },
+ expected: false
+ },
+ {
+ data: {
+ List: {
+ branch: { value: 'No' },
+ items: [
+ {
+ Item: {
+ Relation: {
+ value: 'Father'
+ }
+ }
+ }
+ ]
+ }
+ },
+ expected: false
+ },
+ {
+ data: {
+ List: {
+ branch: { value: 'No' },
+ items: [
+ {
+ Item: {
+ Relation: {
+ value: 'Mother'
+ }
+ }
+ },
+ {
+ Item: {
+ Relation: {
+ value: 'Father'
+ }
+ }
+ }
+ ]
+ }
+ },
+ expected: true
+ }
+ ]
+
+ tests.forEach(test => {
+ expect(new RelativesValidator(test.data).validMinimumRelations()).toBe(
+ test.expected
+ )
+ })
+ })
})
diff --git a/src/validators/releases.js b/src/validators/releases.js
index 23cee2ceb..77242e334 100644
--- a/src/validators/releases.js
+++ b/src/validators/releases.js
@@ -13,38 +13,20 @@ export const hideReleases = (store = {}) => {
export const hideHippa = (store = {}) => {
const psych = store.Psychological || {}
+ const flagged = (question) => {
+ return question && question.value === 'Yes'
+ }
+
const tests = [
- {
- affirmative: (psych, store) => {
- return (psych.Competence || {}).IsIncompetent.value !== 'Yes'
- }
- },
- {
- affirmative: (psych, store) => {
- return (psych.Consultations || {}).Consulted.value !== 'Yes'
- }
- },
- {
- affirmative: (psych, store) => {
- return (psych.Diagnoses || {}).Diagnosed.value !== 'Yes'
- }
- },
- {
- affirmative: (psych, store) => {
- return (psych.Hospitalizations || {}).Hospitalized.value !== 'Yes'
- }
- },
- {
- affirmative: (psych, store) => {
- return (
- hideExistingConditions(store) ||
- (psych.ExistingConditions || {}).HasCondition.value !== 'Yes'
- )
- }
- }
+ (psych.Competence || {}).IsIncompetent,
+ (psych.Consultations || {}).Consulted,
+ (psych.Diagnoses || {}).Diagnosed,
+ (psych.Hospitalizations || {}).Hospitalized,
+ (psych.ExistingConditions || {}).HasCondition
]
- return tests.every(x => x.affirmative(psych, store))
+ const showHippa = tests.some(x => flagged(x))
+ return !showHippa
}
export const formIsSigned = (store = {}) => {
diff --git a/src/validators/selectiveservice.js b/src/validators/selectiveservice.js
index 69d6eb07e..4eee36583 100644
--- a/src/validators/selectiveservice.js
+++ b/src/validators/selectiveservice.js
@@ -41,7 +41,11 @@ export default class SelectiveServiceValidator {
validRegistrationNumber() {
if (this.wasBornAfter === 'Yes' && this.hasRegistered === 'Yes') {
- return validGenericTextfield(this.registrationNumber)
+ return !!(
+ this.registrationNumber &&
+ this.registrationNumber.value &&
+ /^\d*$/g.test(this.registrationNumber.value)
+ )
}
return true
diff --git a/src/validators/selectiveservice.test.js b/src/validators/selectiveservice.test.js
index f6f28089c..c9f3943fa 100644
--- a/src/validators/selectiveservice.test.js
+++ b/src/validators/selectiveservice.test.js
@@ -157,6 +157,16 @@ describe('Selective service validation', function() {
},
expected: false
},
+ {
+ state: {
+ WasBornAfter: { value: 'Yes' },
+ HasRegistered: { value: 'Yes' },
+ RegistrationNumber: {
+ value: '123abc7890'
+ }
+ },
+ expected: false
+ },
{
state: {
WasBornAfter: { value: 'Yes' },