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 26
/
Copy pathfinancialBankruptcy.js
85 lines (80 loc) · 2.2 KB
/
financialBankruptcy.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import name from 'models/shared/name'
import address from 'models/shared/locations/address'
import { hasYesOrNo } from 'models/validate'
import { DEFAULT_LATEST } from 'constants/dateLimits'
const petitionTypes = [
'Chapter7',
'Chapter11',
'Chapter12',
'Chapter13',
]
const financialBankruptcy = {
PetitionType: {
presence: true,
hasValue: {
validator: {
inclusion: petitionTypes,
},
},
},
CourtAddress: {
presence: true,
location: { validator: address },
},
CourtInvolved: { presence: true, hasValue: true },
CourtNumber: { presence: true, hasValue: true },
TotalAmount: {
presence: true,
hasValue: {
validator: { numericality: true },
},
},
DateFiled: (value, attributes, attributeName, options = {}) => {
const { applicantBirthdate } = options
return {
presence: true,
date: { requireDay: false, earliest: applicantBirthdate, latest: DEFAULT_LATEST },
}
},
DateDischarged: (value, attributes) => {
const { DateDischargedNotApplicable, DateFiled } = attributes
if (DateDischargedNotApplicable && DateDischargedNotApplicable.applicable === false) {
return {}
}
const dateLimits = { latest: DEFAULT_LATEST }
if (DateFiled) dateLimits.earliest = DateFiled
return {
presence: true,
date: { requireDay: false, ...dateLimits },
}
},
NameDebt: {
presence: true,
model: { validator: name },
},
// TODO: HasDischargeExplanation is poorly named
// It should be something along the lines of WasBankruptcyDebtsDischarged
HasDischargeExplanation: {
presence: true,
hasValue: { validator: hasYesOrNo },
},
DischargeExplanation: { presence: true, hasValue: true },
Trustee: (value, attributes) => {
const { PetitionType } = attributes
if (PetitionType && PetitionType.value === 'Chapter13') {
return { presence: true, hasValue: true }
}
return {}
},
TrusteeAddress: (value, attributes) => {
const { PetitionType } = attributes
if (PetitionType && PetitionType.value === 'Chapter13') {
return {
presence: true,
location: { validator: address },
}
}
return {}
},
}
export default financialBankruptcy