Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLPAB-2088: Make email optional, channel required for create trust corporation #188

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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