-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add new billing account change address validator #383
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cruikshanks
force-pushed
the
add-change-address-validator
branch
3 times, most recently
from
August 25, 2023 14:03
cf933e3
to
9544512
Compare
https://eaflood.atlassian.net/browse/WATER-4092 We use validators to 'validate' incoming payloads. This new validator will be used to check the content of a request to our new `/billing-accounts/{id}/change-address` endpoint. Though the journey in the UI starts with clicking a **Change address** button during the process you can also change the company and contact linked to the billing account as well. This is why we need to cater for all 3 possibly being sent in the payload. The [Joi](https://joi.dev/) schema we've compiled comes from what we found is currently being used in the legacy code (`water-abstraction-service/src/modules/invoice-accounts/routes.js`).
Cruikshanks
force-pushed
the
add-change-address-validator
branch
from
August 29, 2023 10:56
9544512
to
3f71f8c
Compare
Cruikshanks
added a commit
that referenced
this pull request
Aug 29, 2023
https://eaflood.atlassian.net/browse/WATER-4092 WATER-4092 will require us to add a new 'validator'. These are the modules that contain [Joi](https://joi.dev/) schemas we use to check inbound request payloads. Whilst working on [Add new billing account change address validator](#383) we spotted a few things we wanted to change on the existing validator. As we only have the one, now seemed a good time to make the changes. - fix the test filename (we'd omitted `.test`) - move it out of the `/bill-runs` folder On that last one, similar to [Refactor controllers out of folders](#368) if we find we have lots of validators in the future we'll likely move them into folders. But right now it feels pre-emptive.
These lists are used when validating the address, contact and company data used when changing a billing account's address.
The invalid tests just focus on those that involve checking a value is in one of our static lookups. Those checks in the schema depend on another area of our code so it felt worth while including tests for them. We have a test to show that `address:` is a required property. Beyond that it felt like we'd just be testing Joi which is why every possible invalid data scenario is not covered.
TBH 50/50 on whether this improves things or not. We hope it makes the schemas for the individual properties easy to see and understand so we're going for it. There is an argument though that seeing the whole schema in one place makes it easier to see what Joi is doing. ¯\_(ツ)_/¯
Cruikshanks
force-pushed
the
add-change-address-validator
branch
from
August 29, 2023 11:25
4b89656
to
7f121f3
Compare
Jozzey
approved these changes
Aug 29, 2023
Cruikshanks
added a commit
that referenced
this pull request
Aug 29, 2023
https://eaflood.atlassian.net/browse/WATER-4092 WATER-4092 will require us to add a new 'validator'. These modules contain [Joi](https://joi.dev/) schemas we use to check inbound request payloads. Whilst working on [Add new billing account change address validator](#383) we spotted a few things we wanted to change on the existing validator. As we only have one, now seemed a good time to make the changes. - fix the test filename (we'd omitted `.test`) - move it out of the `/bill-runs` folder On that last one, similar to [Refactor controllers out of folders](#368) if we find we have lots of validators in the future we'll likely move them into folders. But right now it feels pre-emptive.
Cruikshanks
added a commit
that referenced
this pull request
Aug 31, 2023
https://eaflood.atlassian.net/browse/WATER-4092 We are working on migrating the change billing account address functionality from the legacy code to this project. We've previously added a new endpoint and controller that the UI will start using instead of the legacy one. But it is only a dummy, just returning a `201` in response to requests. This change adds the [new change address validator](#383) to the controller. It will mean the controller can validate the incoming requests and handle errors resulting from invalid data. A future final step will add in a new `ChangeAddressService`.
Cruikshanks
added a commit
that referenced
this pull request
Sep 1, 2023
https://eaflood.atlassian.net/browse/WATER-4092 We are working on migrating the change billing account address functionality from the legacy code to this project. We've previously added a new endpoint and controller that the UI will start using instead of the legacy one. But it is only a dummy, just returning a `201` in response to requests. This change adds the [new change address validator](#383) to the controller. It will mean the controller can validate the incoming requests and handle errors resulting from invalid data. A future final step will add in a new `ChangeAddressService`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://eaflood.atlassian.net/browse/WATER-4092
We use validators to 'validate' incoming payloads. This new validator will be used to check the content of a request to our new
/billing-accounts/{id}/change-address
endpoint.Though the journey in the UI starts with clicking a Change address button during the process you can also change the company and contact linked to the billing account as well.
This is why we need to cater for all 3 possibly being sent in the payload.
The Joi schema we've compiled comes from what we found is currently being used in the legacy code (
water-abstraction-service/src/modules/invoice-accounts/routes.js
).