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

Avoid number casting on number values that contain non-digit characters #1002

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aberonni
Copy link

Fixes #1000 by adding an additional check: /^\d+$/.test(value)

I also took the liberty of pulling out the function and (hopefully) increasing readability

I haven't had a chance to test this with real-world data, but I'm hoping there might be integration / unit tests verifying that the updated code works. If not, happy to do some manual tested if needed.

@Helveg
Copy link
Collaborator

Helveg commented Oct 15, 2024

Thanks for the PR! Could you run npm run format so that the tests can run?

There aren't any tests specifically for handling different input values in the filter. If it's not too much to ask you could try adding some of them! You can add a few cases in paginate.spec.ts, here's what we should cover:

  • Send a date input and check that results are correctly filtered.
  • Send a number input and check that results are correctly filtered.
  • Send a number-like input (which shouldn't be treated as a number)

It should be relatively simple to run the spec files with jest, but let me know if you need any help :)

@aberonni
Copy link
Author

@Helveg I got as far as adding the date input test, but struggled a bit with how/where to add the other two, given that there isn't a field (or I couldn't see one) where I could easily add a dummy string for scenario 3.

@Helveg
Copy link
Collaborator

Helveg commented Oct 16, 2024

thanks! I'll take a look to complete the test cases when I have time 👍

@aberonni aberonni marked this pull request as draft October 22, 2024 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

$eq operator is broken with certain string values
3 participants