Correction from @shockey
This commit is contained in:
@@ -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 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
|
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)
|
let err = validateMaxLength(value, maxLength)
|
||||||
if (err) errors.push(err)
|
if (err) errors.push(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ describe("utils", function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("returns a message for invalid input'", function() {
|
it("returns a message for invalid input'", function() {
|
||||||
|
expect(validateMaxLength("abc", 0)).toEqual(errorMessage)
|
||||||
expect(validateMaxLength("abc", 1)).toEqual(errorMessage)
|
expect(validateMaxLength("abc", 1)).toEqual(errorMessage)
|
||||||
expect(validateMaxLength("abc", 2)).toEqual(errorMessage)
|
expect(validateMaxLength("abc", 2)).toEqual(errorMessage)
|
||||||
})
|
})
|
||||||
@@ -272,7 +273,7 @@ describe("utils", function() {
|
|||||||
expect( result ).toEqual( [] )
|
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
|
// invalid string with max length
|
||||||
param = fromJS({
|
param = fromJS({
|
||||||
required: true,
|
required: true,
|
||||||
@@ -283,6 +284,17 @@ describe("utils", function() {
|
|||||||
result = validateParam( param, false )
|
result = validateParam( param, false )
|
||||||
expect( result ).toEqual( ["Value must be less than MaxLength"] )
|
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
|
// invalid string with min length
|
||||||
param = fromJS({
|
param = fromJS({
|
||||||
required: true,
|
required: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user