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

[JENKINS-64439] "positive-number" field validator accepts non valid java numbers #5145

Merged
merged 1 commit into from
Jan 5, 2021

Conversation

benebsiny
Copy link
Contributor

@benebsiny benebsiny commented Dec 30, 2020

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

  • Entry 1: Prevent user to input 'e' or 'E' for the 'positive-number', 'non-negative-number' and 'number'

Proposed upgrade guidelines

N/A

Submitter checklist

  • (If applicable) Jira issue is well described
  • Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change). Examples
    • Fill-in the Proposed changelog entries section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
  • Appropriate autotests or explanation to why this change has no tests
  • For dependency updates: links to external changelogs and, if possible, full diffs

Desired reviewers

@mention

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There are at least 2 approvals for the pull request and no outstanding requests for change
  • Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • Changelog entries in the PR title and/or Proposed changelog entries are correct
  • Proper changelog labels are set so that the changelog can be generated automatically
  • If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

…ava numbers

Prevent user to input 'e' or 'E'.
Except 'positive-number', I also add the restriction to 'non-negative-number' and 'number'
@timja timja added the bug For changelog: Minor bug. Will be listed after features label Jan 2, 2021
Copy link
Member

@oleg-nenashev oleg-nenashev left a 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

@oleg-nenashev oleg-nenashev added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Jan 2, 2021
@oleg-nenashev oleg-nenashev merged commit 663e8f5 into jenkinsci:master Jan 5, 2021
@oleg-nenashev
Copy link
Member

Thanks for your contribution @benebsiny !

event.preventDefault();
}
})
registerRegexpValidator(e,/^(\d+|)$/,"Not an integer");
Copy link
Contributor

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

Copy link
Contributor Author

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', '.'
Copy link
Contributor

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

Copy link
Contributor Author

@benebsiny benebsiny Jan 19, 2021

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'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For changelog: Minor bug. Will be listed after features ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants