-
Notifications
You must be signed in to change notification settings - Fork 4
86b883b71 - Add Numeric Validation for Quantities Fields #761
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
base: master
Are you sure you want to change the base?
86b883b71 - Add Numeric Validation for Quantities Fields #761
Conversation
📝 WalkthroughWalkthroughThis PR introduces a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/components/mui/formik-inputs/mui-formik-quantity-field.js`:
- Around line 7-19: The onKeyDown filter in MuiFormikQuantityField prevents
blocked keys (BLOCKED_KEYS) but paste and drop can still inject
scientific-notation characters; update the MuiFormikQuantityField props passed
to MuiFormikTextField to add onPaste and onDrop handlers that inspect the
pasted/dropped string and if it contains any BLOCKED_KEYS characters or
scientific-notation patterns (e or E with optional sign) call preventDefault()
and stopImmediatePropagation(), otherwise allow the input; reference the
component name MuiFormikQuantityField, the child MuiFormikTextField and the
BLOCKED_KEYS constant when making the change.
In `@src/utils/yup.js`:
- Around line 56-61: The quantityValidation() schema currently uses
yup.number().positive() which rejects 0 and allows decimals, creating a mismatch
with the UI (min: 0) and other validators; replace its implementation to use the
shared positiveNumberValidation() helper (the same used by
quantity_limit_per_sponsor and quantity_limit_per_show) so it enforces integer
and min(0) semantics consistent with the UI and other validators; locate and
swap the body of quantityValidation to delegate to positiveNumberValidation() or
mirror its .integer().min(0) rules and reuse the existing translation keys for
error messages.
♻️ Duplicate comments (1)
src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.js (1)
36-48: Use ofquantityValidationinherits the validator semantics.See the note on
quantityValidationinsrc/utils/yup.js; the same 0/decimal vs integer concern applies here.
🧹 Nitpick comments (1)
src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.js (1)
124-155: Avoid overridingMuiFormikQuantityFielddefaults.Passing
typeandinputPropshere overrides the component’sinputModeand duplicates its own defaults. Consider relying on the wrapper or explicitly merging inputProps.♻️ Streamlined usage
<MuiFormikQuantityField name="quantity_limit_per_show" label={T.translate( "sponsor_form_item_list.edit_item.quantity_limit_per_show" )} fullWidth - type="number" - inputProps={{ min: 0 }} /> ... <MuiFormikQuantityField name="quantity_limit_per_sponsor" label={T.translate( "sponsor_form_item_list.edit_item.quantity_limit_per_sponsor" )} fullWidth - type="number" - inputProps={{ min: 0 }} /> ... <MuiFormikQuantityField name="default_quantity" label={T.translate( "sponsor_form_item_list.edit_item.default_quantity" )} fullWidth - type="number" - inputProps={{ min: 0 }} required />
| standard_rate: decimalValidation(), | ||
| onsite_rate: decimalValidation(), | ||
| default_quantity: positiveNumberValidation(), | ||
| default_quantity: quantityValidation(), |
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.
@niko-exo please dont change the yup validation positiveNumberValidation is the correct one
the fields does not allows decimals

smarcet
left a comment
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.
@niko-exo please review comments
ref: https://app.clickup.com/t/86b883b71
86b883b71 - Add Numeric Validation for Quantities Fields
Changelog
Links
86b883b71 - Add Numeric Validation for Quantities Fields
Evidence
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.