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

Don't enforce validation on paper-channel LPAs #199

Merged
merged 1 commit into from
May 10, 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
7 changes: 5 additions & 2 deletions fixtures/static/js/json-schema-editor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ export class JsonSchemaEditor {

$container.addEventListener("input", (e) => {
if (
e.target instanceof HTMLInputElement ||
e.target instanceof HTMLSelectElement
(e.target instanceof HTMLInputElement ||
e.target instanceof HTMLSelectElement) &&
e.target.name
) {
const value = JSON.parse(this.$module.value);
jsonSet(value, e.target.name, e.target.value);
this.$module.value = JSON.stringify(value);

if (e.target.name === "/channel") this.build();
}
});

Expand Down
4 changes: 4 additions & 0 deletions internal/shared/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func (d *Date) UnmarshalJSON(data []byte) error {
}

func (d *Date) UnmarshalText(data []byte) error {
if len(data) == 0 {
return nil
}

var err error
d.t, err = time.Parse(time.DateOnly, string(data))
return err
Expand Down
5 changes: 3 additions & 2 deletions internal/shared/date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ func TestDateDynamoDB(t *testing.T) {
av := &types.AttributeValueMemberS{Value: tc.dynamo}

var unmarshal Date
attributevalue.Unmarshal(av, &unmarshal)
assert.Nil(t, attributevalue.Unmarshal(av, &unmarshal))
assert.Equal(t, tc.date, unmarshal)

marshal, _ := attributevalue.Marshal(unmarshal)
marshal, err := attributevalue.Marshal(unmarshal)
assert.Nil(t, err)
assert.Equal(t, av, marshal)
})
}
Expand Down
12 changes: 8 additions & 4 deletions lambda/create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@ func (l *Lambda) HandleEvent(ctx context.Context, req events.APIGatewayProxyRequ

// validation
if errs := Validate(input); len(errs) > 0 {
problem := shared.ProblemInvalidRequest
problem.Errors = errs
if input.Channel == shared.ChannelPaper {
l.logger.Info("encountered validation errors in lpa", slog.Any("uid", uid))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the slightly longer term plan for these errors? are we going to store them on the document like sirius does now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still working on that a bit. We know Sirius will need to do validation too, moreso than any done here, to direct caseworkers to anything that needs attention (e.g. R&C != "" is valid, but needs review).

In a perfect world we'd capture these errors and forward them to Sirius (probably through an event) to turn into tasks, but I'm not sure how compatible depending on Sirius's implementation.

Once we get the list of (business-focussed) validation errors through and start speccing up the Sirius work, we can check how we can tie them together.

} else {
problem := shared.ProblemInvalidRequest
problem.Errors = errs

return problem.Respond()
return problem.Respond()
}
}

data := shared.Lpa{LpaInit: input}
data.Uid = uid
data.Status = shared.LpaStatusProcessing
Expand Down