-
Notifications
You must be signed in to change notification settings - Fork 23
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
[SDP-961] Change POST /disbursements
to accept Verification Type
#103
Conversation
stellar-disbursement-platform-backend-preview is available here: |
stellar-disbursement-platform-backend-preview is available here: |
6d4d1b1
to
b9ee6eb
Compare
stellar-disbursement-platform-backend-preview is available here: |
stellar-disbursement-platform-backend-preview is available here: |
VERIFICATION_FIELD_PIN_MIN_LENGTH = 4 | ||
VERIFICATION_FIELD_PIN_MAX_LENGTH = 8 | ||
|
||
VERIFICATION_FIELD_MAX_ID_LENGTH = 50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked with @torisamples on these values
stellar-disbursement-platform-backend-preview is available here: |
stellar-disbursement-platform-backend-preview is available here: |
70ff1df
to
d6c9466
Compare
stellar-disbursement-platform-backend-preview is available here: |
stellar-disbursement-platform-backend-preview is available here: |
@@ -52,16 +54,21 @@ func (d DisbursementHandler) PostDisbursement(w http.ResponseWriter, r *http.Req | |||
return | |||
} | |||
|
|||
// validate request | |||
v := validators.NewValidator() | |||
iv := validators.NewDisbursementInstructionsValidator(disbursementRequest.VerificationField) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need the NewDisbursementInstructionsValidator
as we're not validating instructions at this stage. We're just validating the 5 fields posted when creating a new disbursement.
We should revert this back to v := validators.NewValidator()
and just make sure that VerificationField
is not empty.
v := validators.NewValidator()
v.Check(disbursementRequest.Name != "", "name", "name is required")
v.Check(disbursementRequest.CountryCode != "", "country_code", "country_code is required")
v.Check(disbursementRequest.WalletID != "", "wallet_id", "wallet_id is required")
v.Check(disbursementRequest.AssetID != "", "asset_id", "asset_id is required")
v.Check(disbursementRequest.VerificationField != "", "verification_field", "verification_field is required")
if v.HasErrors() {
httperror.BadRequest("Request invalid", err, v.Errors).Render(w)
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marwen-abid my thinking is that wouldn't we want to make sure that VerificationField
is one of the three existing types? i.e. we decide to add a new verification type but not use it for this endpoint. I know we're technically not validating instructions in this handler but the additional ValidateAndGetVerificationType
call on the NewDisbursementInstructionsValidator
instance provides an additional error messaging for when the type is invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this shortcut is worth it.
the new method you created ValidateAndGetVerificationType
is only used here, so I think it makes more sense to create a new validator called DisbursementRequestValidator
that takes the whole disbursementRequest and validates it. You can move ValidateAndGetVerificationType to that new validator.
stellar-disbursement-platform-backend-preview is available here: |
stellar-disbursement-platform-backend-preview is available here: |
stellar-disbursement-platform-backend-preview is available here: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This looks great 🚀
stellar-disbursement-platform-backend-preview is available here: |
de1714f
to
dbce4d7
Compare
stellar-disbursement-platform-backend-preview is available here: |
stellar-disbursement-platform-backend-preview is available here: |
What
Add verification types to
/disbursement
endpointWhy
Finally leverage validation of verification type for the above endpoint
Known limitations
[TODO or N/A]
Checklist
PR Structure
Thoroughness
Configs and Secrets
values.yaml
file.pr-preview
,dev
,demo
,prd
).values.yaml
file.pr-preview secrets
,dev secrets
,demo secrets
,prd secrets
).Release
develop
ormain
after it's ready for production!Deployment