Skip to content

Discrete and inList validations throw error if data element value is not simple value #73

@srikanthm79

Description

@srikanthm79

What are the steps to reproduce this issue?

Discrete validation:

var validationResult = validate(
target = {
// passing userid as an empty array
"userid": []
},
constraints = {
"userid": { "required": true, "type": "integer","discrete": "gte:1" }
}
);

InList validation:

var validationResult = validate(
    target = {
        "userid": []
    },
    constraints = {
        "userid": { "required": true, "type": "integer","inList": "1,2,3,4,5" }
    }
);

What happens?

DiscreteValidator :

modules\cbvalidation\models\validators\DiscreteValidator.cfc:93
91: }
92: case "gte": {
93: r = ( arguments.targetValue gte operationValue );
94: break;
95: }

Error : "can't compare Complex Object Type Array with a String"

inList validator:

modules\cbvalidation\models\validators\InListValidator.cfc:45
43: listFindNoCase(
44: arguments.validationData,
45: arguments.targetValue
46: )
47: ) {

Error : Can't cast Complex Object Type Array to String

What were you expecting to happen?

Check for data element to be Simplevalue and return error accordingly before Validating.

Any logs, error output, etc?

DiscreteValidator :

modules\cbvalidation\models\validators\DiscreteValidator.cfc:93
91: }
92: case "gte": {
93: r = ( arguments.targetValue gte operationValue );
94: break;
95: }

inList validator:

modules\cbvalidation\models\validators\InListValidator.cfc:45
43: listFindNoCase(
44: arguments.validationData,
45: arguments.targetValue
46: )
47: ) {

Any other comments?

What versions are you using?

Operating System: … Windows 10
Package Version: … "cbvalidation":"^2.1.0+126"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions