@@ -19,11 +19,11 @@ type Name struct {
19
19
// Additional prefix to add to name, like Mrs. or Mr.
20
20
Prefix string `json:"prefix,omitempty" jsonschema:"title=Prefix"`
21
21
// Person's given or first name
22
- Given string `json:"given" jsonschema:"title=Given"`
22
+ Given string `json:"given,omitempty " jsonschema:"title=Given"`
23
23
// Middle names or initials
24
24
Middle string `json:"middle,omitempty" jsonschema:"title=Middle"`
25
25
// Second or Family name.
26
- Surname string `json:"surname" jsonschema:"title=Surname"`
26
+ Surname string `json:"surname,omitempty " jsonschema:"title=Surname"`
27
27
// Additional second of family name.
28
28
Surname2 string `json:"surname2,omitempty" jsonschema:"title=Second Surname"`
29
29
// Titles to include after the name.
@@ -41,8 +41,16 @@ func (n *Name) Validate() error {
41
41
func (n * Name ) ValidateWithContext (ctx context.Context ) error {
42
42
return tax .ValidateStructWithRegime (ctx , n ,
43
43
validation .Field (& n .UUID ),
44
- validation .Field (& n .Given , validation .Required ),
45
- validation .Field (& n .Surname , validation .Required ),
44
+ validation .Field (& n .Given ,
45
+ validation .When (n .Surname == "" ,
46
+ validation .Required ,
47
+ ),
48
+ ),
49
+ validation .Field (& n .Surname ,
50
+ validation .When (n .Given == "" ,
51
+ validation .Required ,
52
+ ),
53
+ ),
46
54
validation .Field (& n .Meta ),
47
55
)
48
56
}
0 commit comments