Skip to content

Commit

Permalink
Correction from @shockey
Browse files Browse the repository at this point in the history
  • Loading branch information
heldersepu committed Sep 29, 2017
1 parent 3a7a8c9 commit a408fb1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ export const validateParam = (param, isXml) => {
let numberCheck = type === "number" && !validateNumber(value) // validateNumber returns undefined if the value is a number
let integerCheck = type === "integer" && !validateInteger(value) // validateInteger returns undefined if the value is an integer

if (maxLength) {
if (maxLength || maxLength === 0) {
let err = validateMaxLength(value, maxLength)
if (err) errors.push(err)
}
Expand Down
14 changes: 13 additions & 1 deletion test/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ describe("utils", function() {
})

it("returns a message for invalid input'", function() {
expect(validateMaxLength("abc", 0)).toEqual(errorMessage)
expect(validateMaxLength("abc", 1)).toEqual(errorMessage)
expect(validateMaxLength("abc", 2)).toEqual(errorMessage)
})
Expand Down Expand Up @@ -272,7 +273,7 @@ describe("utils", function() {
expect( result ).toEqual( [] )
})

it("validates required strings with min and max length", function() {
it("validates required strings with min and max length", function() {
// invalid string with max length
param = fromJS({
required: true,
Expand All @@ -283,6 +284,17 @@ describe("utils", function() {
result = validateParam( param, false )
expect( result ).toEqual( ["Value must be less than MaxLength"] )

// invalid string with max length 0
param = fromJS({
required: true,
type: "string",
value: "test string",
maxLength: 0
})
result = validateParam( param, false )
expect( result ).toEqual( ["Value must be less than MaxLength"] )


// invalid string with min length
param = fromJS({
required: true,
Expand Down

0 comments on commit a408fb1

Please sign in to comment.