Skip to content

Commit

Permalink
Add channel field to LPA
Browse files Browse the repository at this point in the history
To be used in future validation: if the LPA comes through the paper channel then validation wll be more lenient

Originally part of MLPAB-1535 #minor
  • Loading branch information
gregtyler committed May 8, 2024
1 parent 36e7f55 commit 3550633
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/example-lpa.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"lpaType": "personal-welfare",
"channel": "online",
"donor": {
"uid": "eda719db-8880-4dda-8c5d-bb9ea12c236f",
"firstNames": "Feeg",
Expand Down
5 changes: 5 additions & 0 deletions docs/schemas/2024-10/donor-details.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type": "object",
"required": [
"lpaType",
"channel",
"donor",
"attorneys",
"certificateProvider",
Expand All @@ -15,6 +16,10 @@
"type": "string",
"enum": ["property-and-affairs", "personal-welfare"]
},
"channel": {
"type": "string",
"enum": ["paper", "online"]
},
"donor": {
"allOf": [
{
Expand Down
2 changes: 1 addition & 1 deletion fixtures/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h2 class="govuk-error-summary__title">{{ error.detail }}</h2>
required
rows="10"
data-module="json-schema-editor"
data-module-json-schema-editor-url="assets/schemas/2024-10/lpa.json"
data-module-json-schema-editor-url="assets/schemas/2024-10/donor-details.json"
>
{{- json_data -}}
</textarea>
Expand Down
1 change: 1 addition & 0 deletions internal/shared/lpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

type LpaInit struct {
LpaType LpaType `json:"lpaType"`
Channel Channel `json:"channel"`
Donor Donor `json:"donor"`
Attorneys []Attorney `json:"attorneys"`
TrustCorporations []TrustCorporation `json:"trustCorporations,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion internal/shared/lpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestLpaInitMarshalJSON(t *testing.T) {
expected := `{
"lpaType":"",
"lpaType":"","channel":"",
"donor":{"uid":"","firstNames":"","lastName":"","address":{"line1":"","country":""},"dateOfBirth":"","email":"","contactLanguagePreference":""},
"attorneys":null,
"certificateProvider":{"uid":"","firstNames":"","lastName":"","address":{"line1":"","country":""},"email":"","phone":"","channel":""},
Expand Down
1 change: 1 addition & 0 deletions lambda/create/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func Validate(lpa shared.LpaInit) []shared.FieldError {

return validate.All(
validate.IsValid("/lpaType", lpa.LpaType),
validate.IsValid("/channel", lpa.Channel),
validate.UUID("/donor/uid", lpa.Donor.UID),
validate.Required("/donor/firstNames", lpa.Donor.FirstNames),
validate.Required("/donor/lastName", lpa.Donor.LastName),
Expand Down
2 changes: 2 additions & 0 deletions lambda/create/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func makeTrustCorporation() shared.TrustCorporation {
func makeLpaWithDonorAndActors() shared.LpaInit {
return shared.LpaInit{
LpaType: shared.LpaTypePropertyAndAffairs,
Channel: shared.ChannelOnline,
Donor: shared.Donor{
Person: shared.Person{
UID: "b99af83d-5b6c-44f7-8c03-14004699bdb9",
Expand Down Expand Up @@ -192,6 +193,7 @@ func TestValidateLpaInvalid(t *testing.T) {
lpa: func() shared.LpaInit { return shared.LpaInit{} },
expectedErrors: []shared.FieldError{
{Source: "/lpaType", Detail: "field is required"},
{Source: "/channel", Detail: "field is required"},
{Source: "/donor/uid", Detail: "field is required"},
{Source: "/donor/firstNames", Detail: "field is required"},
{Source: "/donor/lastName", Detail: "field is required"},
Expand Down
1 change: 1 addition & 0 deletions mock-apigw/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func handlePactState(r *http.Request) error {
url := fmt.Sprintf("http://localhost:8080/lpas/%s", oldUID)
body := `{
"lpaType": "personal-welfare",
"channel": "online",
"donor": {
"uid": "34cd75eb-17bc-434a-b922-4772ce3e0439",
"firstNames": "Homer",
Expand Down

0 comments on commit 3550633

Please sign in to comment.