-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
[JENKINS-64439] "positive-number" field validator accepts non valid java numbers #5145
Conversation
…ava numbers Prevent user to input 'e' or 'E'. Except 'positive-number', I also add the restriction to 'non-negative-number' and 'number'
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.
It would be nice to deduplicate the code, but it looks good operation-wise.
We may merge it in 24 hours if there is no negative feedback. Please see the merge process documentation for more information about the merge process
Thanks for your contribution @benebsiny ! |
event.preventDefault(); | ||
} | ||
}) | ||
registerRegexpValidator(e,/^(\d+|)$/,"Not an integer"); |
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.
Now a number cannot be a negative number
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.
I didn't modified it. It seems that it need be modified. How about ^(-?\d+|)$
?
registerRegexpValidator(e,/^(\d*[1-9]\d*|)$/,"Not a positive integer"); | ||
}); | ||
|
||
Behaviour.specify("INPUT.positive-number-required", "input-positive-number-required", ++p, function(e) { | ||
e.addEventListener('keypress', function (event) { | ||
if (event.which === 69 || event.which === 101) { // Prevent user input 'e', 'E', '.' |
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.
The '.'
is not included in the if
clause
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.
I forgot to add it. I feel so sorry.
By the way, is it a good idea to add '.'
constraint for all input validator? Because some error message shows "Not an integer" and other shows "Not a non-negative number". The point is the difference between them is number and integer.
I'm thinking that should I add the '.'
constraint for the messages which contain 'integer', or change the messages which contain 'number' to 'integer'?
Prevent user to input 'e' or 'E'.
Except 'positive-number', I also add the restriction to 'non-negative-number' and 'number'
See JENKINS-64439.
Proposed changelog entries
Proposed upgrade guidelines
N/A
Submitter checklist
Proposed changelog entries
section only if there are breaking changes or other changes which may require extra steps from users during the upgradeDesired reviewers
@mention
Maintainer checklist
Before the changes are marked as
ready-for-merge
:Proposed changelog entries
are correctupgrade-guide-needed
label is set and there is aProposed upgrade guidelines
section in the PR title. (example)lts-candidate
to be considered (see query).