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

Update Input Validation #1644

Merged
merged 1 commit into from
Oct 3, 2024
Merged

Conversation

deannaflare
Copy link
Contributor

Summary

This PR updates the input validations for the bank page and the exchanges page

The bank names should now auto format on blur.

Test Plan

Tested locally:

Bank Page:

  • Enter different bank names. For invalid names, verify that the "Create New Bank" button is disabled and you see the appropriate error message
  • Enter different bank names. For valid names, verify that the "Create New Bank" button is not disabled and is submittable and you do not see an error message
  • Enter an existing bank name. Verify that you see an alert instead of being redirected for an error page.

Exchanges Page (create exchange form):

  • Enter different bank names. For invalid names, verify that you see the appropriate error message and the "Create" button is disabled
  • Enter an invalid json text. Verify that the "Create" button is disabled and you see the appropriate error message and the "Create" button is disabled
  • If the form is valid, verify that the form is submittable

Screenshots

Screenshot 2024-10-03 at 12 34 10 PM Screenshot 2024-10-03 at 12 34 54 PM

@facebook-github-bot
Copy link
Contributor

Hi @deannaflare!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@@ -285,7 +285,7 @@ def exchange_create():
api_type_name = data.get("api")

if not re.match("^[A-Z0-9_]+$", bank):
abort(400, "Field `bank` must match /^[A-Z0-9_]$/")
abort(400, "Field `bank` must match /^[A-Z0-9_]+$/")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this was a typo? Updated it because the message doesn't match regex actually being called?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, typo. We can also explain it in english if that's easier.

Copy link
Contributor

@Dcallies Dcallies left a comment

Choose a reason for hiding this comment

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

I am not smrt enough to read javascript, but your test plan looks convincing. Sign CLA and let's confirm CI passes and we are good to go.

@@ -285,7 +285,7 @@ def exchange_create():
api_type_name = data.get("api")

if not re.match("^[A-Z0-9_]+$", bank):
abort(400, "Field `bank` must match /^[A-Z0-9_]$/")
abort(400, "Field `bank` must match /^[A-Z0-9_]+$/")
Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, typo. We can also explain it in english if that's easier.

<script>
document.getElementById('create_bank_bank_name').addEventListener('blur', function() {
const bankNameField = this;
Copy link
Contributor

Choose a reason for hiding this comment

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

fancy!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@dougneal dougneal merged commit f45282b into facebook:main Oct 3, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants