Skip to content

fix: validate workout exercise inputs - #41

Open
NAND-369 wants to merge 1 commit into
arvids-unavailable:mainfrom
NAND-369:fix/input-validation
Open

fix: validate workout exercise inputs#41
NAND-369 wants to merge 1 commit into
arvids-unavailable:mainfrom
NAND-369:fix/input-validation

Conversation

@NAND-369

Copy link
Copy Markdown

Summary

Closes #35

  • Add frontend validation for exercise reps, sets, and weight
  • Prevent negative reps, sets, and weight
  • Prevent decimal values for reps and sets
  • Allow decimal values for weight
  • Reject NaN, Infinity, and non-numeric values
  • Add backend validation before workout state persistence
  • Return HTTP 400 for invalid workout data
  • Add frontend and backend regression tests

Implementation

Frontend

  • Added validation.js
  • Added validation guards to Workout.jsx
  • Improved NumberField and Stepper
  • Added validation regression tests

Backend

  • Added api/validation.js
  • Added validation to PUT /api/data
  • Invalid workout state is rejected before atomicWrite()
  • Added backend regression tests
  • Added npm test script

Verification

  • Frontend: 219 tests passed
  • Backend: 21 tests passed
  • git diff --check: clean

@SunriseDuarte

Copy link
Copy Markdown

Heads up: openGym has moved to GitLab.
-> GitLab

The GitHub repo is no longer maintained (the account was suspended, so it's out of my hands). Please re-open this issue/PR on GitLab so it doesn't get lost, I'll pick it up there. Questions, help and roadmap discussion now happen in Discord:
-> Discord

Sorry for the noise, and thanks for sticking around.
more infos here: openGym

@NAND-369

Copy link
Copy Markdown
Author

Thanks for the heads-up! I’ve moved the contribution to GitLab and reopened Issue #35 there.

New MR: https://gitlab.com/DuarteSantos8/opengym/-/merge_requests/33

The validation changes have been ported to the current GitLab main branch, and the GitLab CI pipeline is passing. Thanks for maintaining the project!

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.

Missing input validation on exercise sets/reps (accepts negative values and decimals)

2 participants