Correction from @shockey

This commit is contained in:
HelderSepu
2017-09-28 20:40:16 -04:00
parent 3a7a8c9c67
commit a408fb1f23
2 changed files with 14 additions and 2 deletions

View File

@@ -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)
}

View File

@@ -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)
})
@@ -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,
@@ -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,