Skip to content

Commit a78278e

Browse files
fix(utils): fix error messages for range validation of number parameters (#10344)
1 parent dfc0c2b commit a78278e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/core/utils/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,13 @@ export const propChecker = (props, nextProps, objectList=[], ignoreList=[]) => {
304304

305305
export const validateMaximum = ( val, max ) => {
306306
if (val > max) {
307-
return `Value must be less than ${max}`
307+
return `Value must be less than or equal to ${max}`
308308
}
309309
}
310310

311311
export const validateMinimum = ( val, min ) => {
312312
if (val < min) {
313-
return `Value must be greater than ${min}`
313+
return `Value must be greater than or equal to ${min}`
314314
}
315315
}
316316

test/unit/core/utils.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ describe("utils", () => {
147147
})
148148

149149
it("returns a message for invalid input", () => {
150-
expect(validateMaximum(1, 0)).toEqual("Value must be less than 0")
151-
expect(validateMaximum(10, 9)).toEqual("Value must be less than 9")
152-
expect(validateMaximum(20, 19)).toEqual("Value must be less than 19")
150+
expect(validateMaximum(1, 0)).toEqual("Value must be less than or equal to 0")
151+
expect(validateMaximum(10, 9)).toEqual("Value must be less than or equal to 9")
152+
expect(validateMaximum(20, 19)).toEqual("Value must be less than or equal to 19")
153153
})
154154
})
155155

@@ -160,9 +160,9 @@ describe("utils", () => {
160160
})
161161

162162
it("returns a message for invalid input", () => {
163-
expect(validateMinimum(-1, 0)).toEqual("Value must be greater than 0")
164-
expect(validateMinimum(1, 2)).toEqual("Value must be greater than 2")
165-
expect(validateMinimum(10, 20)).toEqual("Value must be greater than 20")
163+
expect(validateMinimum(-1, 0)).toEqual("Value must be greater than or equal to 0")
164+
expect(validateMinimum(1, 2)).toEqual("Value must be greater than or equal to 2")
165+
expect(validateMinimum(10, 20)).toEqual("Value must be greater than or equal to 20")
166166
})
167167
})
168168

@@ -940,7 +940,7 @@ describe("utils", () => {
940940
maximum: 0
941941
}
942942
value = 1
943-
assertValidateParam(param, value, ["Value must be less than 0"])
943+
assertValidateParam(param, value, ["Value must be less than or equal to 0"])
944944

945945
// invalid number with minimum:0
946946
param = {
@@ -949,7 +949,7 @@ describe("utils", () => {
949949
minimum: 0
950950
}
951951
value = -10
952-
assertValidateParam(param, value, ["Value must be greater than 0"])
952+
assertValidateParam(param, value, ["Value must be greater than or equal to 0"])
953953
})
954954

955955
it("validates optional numbers", () => {

0 commit comments

Comments
 (0)