This repository was archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathcitizenship.js
More file actions
49 lines (45 loc) · 1.52 KB
/
Copy pathcitizenship.js
File metadata and controls
49 lines (45 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { hasYesOrNo } from 'models/validate'
import { DEFAULT_LATEST } from 'constants/dateLimits'
// This is an array for some reason.
const isUnitedStates = value => value && value.includes('United States')
const citizenship = {
Country: { presence: true, country: true },
Dates: (value, attributes, attributeName, options = {}) => {
const { applicantBirthdate } = options
return {
presence: true,
daterange: { earliest: applicantBirthdate, latest: DEFAULT_LATEST },
}
},
Current: (value, attributes) => (
(attributes.Dates && !attributes.Dates.present)
? { presence: true, hasValue: { validator: hasYesOrNo } }
: {}
),
CurrentExplanation: (value, attributes) => (
(attributes.Dates && !attributes.Dates.present)
? { presence: true, hasValue: true }
: {}
),
How: (value, attributes) => (
(!attributes.Country || isUnitedStates(attributes.Country.value))
? {}
: { presence: true, hasValue: true }
),
Renounced: (value, attributes, attributeName, options) => (
((!attributes.Country || isUnitedStates(attributes.Country.value))
|| !options.requireCitizenshipRenounced)
? {}
: {
presence: true,
hasValue: { validator: hasYesOrNo },
}
),
RenouncedExplanation: (value, attributes, attributeName, options) => (
((!attributes.Country || isUnitedStates(attributes.Country.value))
|| !options.requireCitizenshipRenounced)
? {}
: { presence: true, hasValue: true }
),
}
export default citizenship