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

Fix error msg for out-of-range value of int param #10185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,13 @@ export const propChecker = (props, nextProps, objectList=[], ignoreList=[]) => {

export const validateMaximum = ( val, max ) => {
if (val > max) {
return `Value must be less than ${max}`
return `Value must be less than or equal to ${max}`
}
}

export const validateMinimum = ( val, min ) => {
if (val < min) {
return `Value must be greater than ${min}`
return `Value must be greater than or equal to ${min}`
}
}

Expand Down
12 changes: 6 additions & 6 deletions test/unit/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ describe("utils", () => {
})

it("returns a message for invalid input", () => {
expect(validateMaximum(1, 0)).toEqual("Value must be less than 0")
expect(validateMaximum(10, 9)).toEqual("Value must be less than 9")
expect(validateMaximum(20, 19)).toEqual("Value must be less than 19")
expect(validateMaximum(1, 0)).toEqual("Value must be less than or equal to 0")
expect(validateMaximum(10, 9)).toEqual("Value must be less than or equal to 9")
expect(validateMaximum(20, 19)).toEqual("Value must be less than or equal to 19")
})
})

Expand All @@ -160,9 +160,9 @@ describe("utils", () => {
})

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

Expand Down