Skip to content

Commit 795839c

Browse files
authored
MaritalStatus as new IdentityAttribute (#887)
* refactor: remove unnecessary comment * feat: add MaritalStatus IdentityAttribute value type * feat: make MaritalStatus useable * chore: build Schema.ts * test: add DVO tests for MaritalStatus * feat: add civil partnership statuses * feat: add source for marital status in Germany
1 parent 255d443 commit 795839c

File tree

8 files changed

+388
-6
lines changed

8 files changed

+388
-6
lines changed

packages/content/src/attributes/AttributeValueTypes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
IHonorificSuffix,
4949
IIdentityFileReference,
5050
IJobTitle,
51+
IMaritalStatus,
5152
IMiddleName,
5253
INationality,
5354
IPhoneNumber,
@@ -73,6 +74,8 @@ import {
7374
IWebsite,
7475
JobTitle,
7576
JobTitleJSON,
77+
MaritalStatus,
78+
MaritalStatusJSON,
7679
MiddleName,
7780
MiddleNameJSON,
7881
Nationality,
@@ -143,6 +146,7 @@ export namespace AttributeValues {
143146
| HonorificSuffixJSON
144147
| IdentityFileReferenceJSON
145148
| JobTitleJSON
149+
| MaritalStatusJSON
146150
| MiddleNameJSON
147151
| NationalityJSON
148152
| PhoneNumberJSON
@@ -170,6 +174,7 @@ export namespace AttributeValues {
170174
| IHonorificSuffix
171175
| IIdentityFileReference
172176
| IJobTitle
177+
| IMaritalStatus
173178
| IMiddleName
174179
| INationality
175180
| IPhoneNumber
@@ -197,6 +202,7 @@ export namespace AttributeValues {
197202
| HonorificSuffix
198203
| IdentityFileReference
199204
| JobTitle
205+
| MaritalStatus
200206
| MiddleName
201207
| Nationality
202208
| PhoneNumber
@@ -224,6 +230,7 @@ export namespace AttributeValues {
224230
HonorificSuffix,
225231
IdentityFileReference,
226232
JobTitle,
233+
MaritalStatus,
227234
MiddleName,
228235
Nationality,
229236
PhoneNumber,
@@ -253,6 +260,7 @@ export namespace AttributeValues {
253260
"IdentityFileReference",
254261
"JobTitle",
255262
"Nationality",
263+
"MaritalStatus",
256264
"MiddleName",
257265
"PhoneNumber",
258266
"PostOfficeBoxAddress",
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { serialize, type, validate } from "@js-soft/ts-serval";
2+
import { RenderHints, RenderHintsEditType, ValueHints, ValueHintsValue } from "../../../attributes/hints";
3+
import { AbstractString, AbstractStringJSON, IAbstractString } from "../AbstractString";
4+
5+
/**
6+
* Particularly reflects marital status in Germany according to https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Bevoelkerung/Haushalte-Familien/Glossar/familienstand.html
7+
*/
8+
export enum MaritalStatusValue {
9+
Single = "single",
10+
Married = "married",
11+
Separated = "separated",
12+
Divorced = "divorced",
13+
Widowed = "widowed",
14+
CivilPartnership = "civilPartnership",
15+
CivilPartnershipDissolved = "civilPartnershipDissolved",
16+
CivilPartnerDeceased = "civilPartnerDeceased"
17+
}
18+
19+
export interface MaritalStatusJSON extends AbstractStringJSON {
20+
"@type": "MaritalStatus";
21+
}
22+
23+
export interface IMaritalStatus extends IAbstractString {}
24+
25+
@type("MaritalStatus")
26+
export class MaritalStatus extends AbstractString {
27+
@serialize()
28+
@validate({
29+
customValidator: (v) => (!Object.values(MaritalStatusValue).includes(v) ? `must be one of: ${Object.values(MaritalStatusValue)}` : undefined)
30+
})
31+
public override value: MaritalStatusValue;
32+
33+
public static override get valueHints(): ValueHints {
34+
return super.valueHints.copyWith({
35+
values: Object.values(MaritalStatusValue).map((value) => ValueHintsValue.from({ key: value, displayName: `i18n://attributes.values.maritalStatus.${value}` }))
36+
});
37+
}
38+
39+
public static override get renderHints(): RenderHints {
40+
return super.renderHints.copyWith({
41+
editType: RenderHintsEditType.ButtonLike
42+
});
43+
}
44+
45+
public static from(value: IMaritalStatus | Omit<MaritalStatusJSON, "@type"> | string): MaritalStatus {
46+
return this.fromAny(value);
47+
}
48+
49+
public override toJSON(verbose?: boolean | undefined, serializeAsString?: boolean | undefined): MaritalStatusJSON {
50+
return super.toJSON(verbose, serializeAsString) as MaritalStatusJSON;
51+
}
52+
}

packages/content/src/attributes/types/person/Sex.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import { serialize, type, validate } from "@js-soft/ts-serval";
22
import { RenderHints, RenderHintsEditType, ValueHints, ValueHintsValue } from "../../../attributes/hints";
33
import { AbstractString, AbstractStringJSON, IAbstractString } from "../AbstractString";
44

5-
/**
6-
* Biologisches Geschlecht
7-
*/
85
export enum BiologicalSex {
96
X = "intersex",
107
F = "female",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from "./Citizenship";
22
export * from "./JobTitle";
3+
export * from "./MaritalStatus";
34
export * from "./Nationality";
45
export * from "./Sex";

0 commit comments

Comments
 (0)