Skip to content

Commit

Permalink
vega-2431 - Remove 'town' as required field in address (#185)
Browse files Browse the repository at this point in the history
* Remove 'town' as required field in address vega-2431#minor

* Remove more tests that assert town as required
  • Loading branch information
mabely authored Apr 30, 2024
1 parent 6c19017 commit 5f0abea
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/schemas/2024-04/donor-details.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"$defs": {
"Address": {
"type": "object",
"required": ["line1", "town", "country"],
"required": ["line1", "country"],
"properties": {
"line1": {
"type": "string",
Expand Down
4 changes: 2 additions & 2 deletions internal/shared/lpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
func TestLpaInitMarshalJSON(t *testing.T) {
expected := `{
"lpaType":"",
"donor":{"uid":"","firstNames":"","lastName":"","address":{"line1":"","town":"","country":""},"dateOfBirth":"","email":"","contactLanguagePreference":""},
"donor":{"uid":"","firstNames":"","lastName":"","address":{"line1":"","country":""},"dateOfBirth":"","email":"","contactLanguagePreference":""},
"attorneys":null,
"certificateProvider":{"uid":"","firstNames":"","lastName":"","address":{"line1":"","town":"","country":""},"email":"","phone":"","channel":""},
"certificateProvider":{"uid":"","firstNames":"","lastName":"","address":{"line1":"","country":""},"email":"","phone":"","channel":""},
"signedAt":"0001-01-01T00:00:00Z"
}`

Expand Down
2 changes: 1 addition & 1 deletion internal/shared/person.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Address struct {
Line1 string `json:"line1"`
Line2 string `json:"line2,omitempty"`
Line3 string `json:"line3,omitempty"`
Town string `json:"town"`
Town string `json:"town,omitempty"`
Postcode string `json:"postcode,omitempty"`
Country string `json:"country"`
}
Expand Down
1 change: 0 additions & 1 deletion internal/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func OptionalTime(source string, t *time.Time) []shared.FieldError {
func Address(prefix string, address shared.Address) []shared.FieldError {
return All(
Required(fmt.Sprintf("%s/line1", prefix), address.Line1),
Required(fmt.Sprintf("%s/town", prefix), address.Town),
Required(fmt.Sprintf("%s/country", prefix), address.Country),
Country(fmt.Sprintf("%s/country", prefix), address.Country),
)
Expand Down
3 changes: 0 additions & 3 deletions internal/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

var validAddress = shared.Address{
Line1: "123 Main St",
Town: "Homeland",
Country: "GB",
}

Expand Down Expand Up @@ -86,7 +85,6 @@ func TestAddressEmpty(t *testing.T) {
errors := Address("/test", address)

assert.Contains(t, errors, shared.FieldError{Source: "/test/line1", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/town", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/country", Detail: "field is required"})
}

Expand All @@ -99,7 +97,6 @@ func TestAddressValid(t *testing.T) {
func TestAddressInvalidCountry(t *testing.T) {
invalidAddress := shared.Address{
Line1: "123 Main St",
Town: "Homeland",
Country: "United Kingdom",
}
errors := Address("/test", invalidAddress)
Expand Down
3 changes: 0 additions & 3 deletions lambda/create/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

var validAddress = shared.Address{
Line1: "123 Main St",
Town: "Homeland",
Country: "GB",
}

Expand Down Expand Up @@ -46,7 +45,6 @@ func TestValidateAttorneyEmpty(t *testing.T) {
assert.Contains(t, errors, shared.FieldError{Source: "/test/status", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/dateOfBirth", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/address/line1", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/address/town", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/address/country", Detail: "field is required"})
}

Expand Down Expand Up @@ -105,7 +103,6 @@ func TestValidateTrustCorporationEmpty(t *testing.T) {
assert.Contains(t, errors, shared.FieldError{Source: "/test/email", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/status", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/address/line1", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/address/town", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/address/country", Detail: "field is required"})
}

Expand Down

0 comments on commit 5f0abea

Please sign in to comment.