Skip to content

Commit

Permalink
MLPAB-2088: Make email optional, channel required for create trust co…
Browse files Browse the repository at this point in the history
…rporation (#188)
  • Loading branch information
acsauk authored May 1, 2024
1 parent 19f61aa commit 989c8e8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lambda/create/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ func validateTrustCorporation(prefix string, trustCorporation shared.TrustCorpor
validate.UUID(fmt.Sprintf("%s/uid", prefix), trustCorporation.UID),
validate.Required(fmt.Sprintf("%s/name", prefix), trustCorporation.Name),
validate.Required(fmt.Sprintf("%s/companyNumber", prefix), trustCorporation.CompanyNumber),
validate.Required(fmt.Sprintf("%s/email", prefix), trustCorporation.Email),
validate.Address(fmt.Sprintf("%s/address", prefix), trustCorporation.Address),
validate.IsValid(fmt.Sprintf("%s/channel", prefix), trustCorporation.Channel),
validate.IsValid(fmt.Sprintf("%s/status", prefix), trustCorporation.Status),
//validate.IfElse(trustCorporation.Channel == shared.ChannelOnline,
// validate.Required(fmt.Sprintf("%s/email", prefix), trustCorporation.Email),
// validate.Empty(fmt.Sprintf("%s/email", prefix), trustCorporation.Email)),
)
}
28 changes: 27 additions & 1 deletion lambda/create/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ func TestValidateTrustCorporationEmpty(t *testing.T) {

assert.Contains(t, errors, shared.FieldError{Source: "/test/name", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/companyNumber", Detail: "field is required"})
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/country", Detail: "field is required"})
assert.Contains(t, errors, shared.FieldError{Source: "/test/channel", Detail: "field is required"})
}

func TestValidateTrustCorporationValid(t *testing.T) {
Expand All @@ -114,6 +114,7 @@ func TestValidateTrustCorporationValid(t *testing.T) {
Email: "[email protected]",
Address: validAddress,
Status: shared.AttorneyStatusActive,
Channel: shared.ChannelOnline,
}
errors := validateTrustCorporation("/test", trustCorporation)

Expand Down Expand Up @@ -298,6 +299,31 @@ func TestValidateLpaInvalid(t *testing.T) {
{Source: "/lifeSustainingTreatmentOption", Detail: "field must not be provided"},
},
},
//"online trust corporation missing email": {
// lpa: shared.LpaInit{
// TrustCorporations: []shared.TrustCorporation{
// {
// Channel: shared.ChannelOnline,
// },
// },
// },
// contains: []shared.FieldError{
// {Source: "/trustCorporations/0/email", Detail: "field is required"},
// },
//},
//"paper trust corporation with email": {
// lpa: shared.LpaInit{
// TrustCorporations: []shared.TrustCorporation{
// {
// Channel: shared.ChannelPaper,
// Email: "[email protected]",
// },
// },
// },
// contains: []shared.FieldError{
// {Source: "/trustCorporations/0/email", Detail: "field must not be provided"},
// },
//},
}

for name, tc := range testcases {
Expand Down

0 comments on commit 989c8e8

Please sign in to comment.