Skip to content

Commit 0cbf72b

Browse files
jeromepochatlemeurherve
authored andcommitted
[JENKINS-76002] Apply number instead of string comparison (jenkinsci#11059)
(cherry picked from commit 88dd0bf)
1 parent f0d65eb commit 0cbf72b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

war/src/main/webapp/scripts/hudson-behavior.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -821,16 +821,16 @@ function registerMinMaxValidator(e) {
821821
}
822822

823823
if (isInteger(this.value)) {
824+
const valueInt = parseInt(this.value);
825+
824826
// Ensure the value is an integer
825827
if (min !== null && isInteger(min) && max !== null && isInteger(max)) {
826828
// Both min and max attributes are available
827-
828-
if (min <= max) {
829+
const minInt = parseInt(min);
830+
const maxInt = parseInt(max);
831+
if (minInt <= maxInt) {
829832
// Add the validator if min <= max
830-
if (
831-
parseInt(min) > parseInt(this.value) ||
832-
parseInt(this.value) > parseInt(max)
833-
) {
833+
if (minInt > valueInt || valueInt > maxInt) {
834834
// The value is out of range
835835
updateValidationArea(
836836
this.targetElement,
@@ -850,7 +850,8 @@ function registerMinMaxValidator(e) {
850850
) {
851851
// There is only 'min' available
852852

853-
if (parseInt(min) > parseInt(this.value)) {
853+
const minInt = parseInt(min);
854+
if (minInt > valueInt) {
854855
updateValidationArea(
855856
this.targetElement,
856857
`<div class="error">This value should be larger than ${min}</div>`,
@@ -868,7 +869,8 @@ function registerMinMaxValidator(e) {
868869
) {
869870
// There is only 'max' available
870871

871-
if (parseInt(max) < parseInt(this.value)) {
872+
const maxInt = parseInt(max);
873+
if (maxInt < valueInt) {
872874
updateValidationArea(
873875
this.targetElement,
874876
`<div class="error">This value should be less than ${max}</div>`,

0 commit comments

Comments
 (0)