validateModel error

With Coldbox 4.0 I am getting the following validation error

invalid call of the function processRules(xxxxxx\modules\cbvalidation\models\ValidationManager.cfc), first Argument (results) is of invalid type, can’t cast Object type [Component cbvalidation.models.result.ValidationResult] to a value of type [cbvalidation.models.result.ivalidationresult]

this is happening when I invoke populateModel(entity) with a new orm entity of a type that extends cborm.models.ActiveEntity

Anyone any ideas?

Thanks

Does that CFC implement the iValidatioNResult interface?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

No, but surely it shouldn’t need to. It’s the result object that will implement the interface no?

This is the code I am running inside a handler, User being an entity in the ORM which extends cborm.models.ActiveEntity

var user= populateModel( entityNew(“User”) );
prc.validationResults = validateModel( user);

Thanks

I was going off the error message:

can’t cast Object type [Component cbvalidation.models.result.ValidationResult] to a value of type [cbvalidation.models.result.ivalidationresult]

So “that CFC” meant cbvalidation.models.result.ValidationResult

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Ah ok. Is that not something that is created inside the validation module and returned to me?, I am not doing anything complex.

I have a CFC ORM entity, User. It extends cborm.models.ActiveEntity, has a constraints structure.

I then have a handler which is running the code I listed above, simply created a new User and passing it into validateModel

var user= populateModel( entityNew(“User”) );
prc.validationResults = validateModel( user);

The second line creates the error, with it generating inside \modules\cbvalidation\models\ValidationManager.cfc at line 129, when the processRules method invokes

I was expecting that it would just return me an array of errors into my prc.validationResults object

The answer is yes :slight_smile:

https://github.com/ColdBox/cbox-validation/blob/master/modules/cbvalidation/models/result/ValidationResult.cfc#L9

What CFML engine are you using? Adobe, Railo, Lucee, etc? It may be a bug related to how the CFC namespace is being imported.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Ah ok, I’m using Lucee

For reference, running the same code on Railo works fine. No error :confused:

That’s interesting. I wonder if there’s a regression from Railo to Lucee. I would recommend starting a thread over on the Lucee list with a simple example and ask about it.

https://groups.google.com/forum/?hl=en#!forum/lucee

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com