fix(ui): allow negative values in validate-number-range (#40818)#40835
Open
lbajsarowicz wants to merge 1 commit into
Open
fix(ui): allow negative values in validate-number-range (#40818)#40835lbajsarowicz wants to merge 1 commit into
lbajsarowicz wants to merge 1 commit into
Conversation
ACP2E-3867 added a pre-check `/^(?:\d+\.?\d*|\.\d+)$/` to the validate-number-range rule. The regex rejected any leading minus sign, so UI components that declared a range like `validate-number-range -99-10000` broke for legitimate negative inputs even though the range explicitly allowed them. The dataAttrRange regex on the very next line already supports `-?` on both bounds, so the upstream short-circuit was the only blocker. Allow an optional leading `-` in the numeric pre-check. Update the jasmine spec to reflect the correct expected behaviour for negative ranges (previously the spec was asserting the buggy result) and add coverage for the mixed-sign range case from magento#40818. Fixes magento#40818
|
Hi @lbajsarowicz. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
Contributor
Author
|
@magento run all tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ACP2E-3867 added a numeric pre-check
/^(?:\d+\.?\d*|\.\d+)$/tovalidate-number-range. The regex rejects any leading minus sign, so UIcomponents declaring a range like
validate-number-range -99-10000rejectlegitimate negative inputs even though the range explicitly allows them.
The dataAttrRange regex on the very next line already accepts
-?onboth bounds, so the upstream short-circuit was the only blocker. Allow
an optional leading
-in the numeric pre-check.Updated the jasmine spec to reflect the correct expected behaviour for
negative ranges (the existing test was asserting the buggy result) and
added coverage for the mixed-sign range case from the issue.
Fixes #40818
Fixed Issues
Manual testing scenarios
Declare a UI component field with:
Before: any negative input fails with
The value is not within the specified range.After: negatives within the range pass; values outside the range still fail.
Contribution checklist