-
Notifications
You must be signed in to change notification settings - Fork 22
/
married_out_of_range.go
39 lines (32 loc) · 1.13 KB
/
married_out_of_range.go
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
package gedcom
import "fmt"
// MarriedOutOfRangeWarning is raised when the age of an individual at the time
// they were married is less than 16 (DefaultMinMarriageAge) or greater than 100
// (DefaultMaxMarriageAge).
type MarriedOutOfRangeWarning struct {
SimpleWarning
Family *FamilyNode
Spouse *IndividualNode
YearsOldAtMarriage float64
// Either "young" or "old" to indicate which boundary was breached.
Boundary string
}
func NewMarriedOutOfRangeWarning(family *FamilyNode, spouse *IndividualNode, yearsOldAtMarriage float64, boundary string) *MarriedOutOfRangeWarning {
return &MarriedOutOfRangeWarning{
Family: family,
Spouse: spouse,
YearsOldAtMarriage: yearsOldAtMarriage,
Boundary: boundary,
}
}
func (w *MarriedOutOfRangeWarning) Name() string {
return "MarriedOutOfRange"
}
func (w *MarriedOutOfRangeWarning) String() string {
partnerName := "husband"
if w.Family.Wife().IsIndividual(w.Spouse) {
partnerName = "wife"
}
return fmt.Sprintf("The %s %s married too %s at %.0f years old.",
partnerName, w.Spouse.String(), w.Boundary, w.YearsOldAtMarriage)
}