[Coldbox 3.5.2] Validation on ColdFusion 8

I am trying to use the built-in validations on a bean that I am creating in ColdFusion 8.

Here is the bean:

this.constraints = { cat_desc = {required=true}, cat_short_desc = {required=true} }; variables.instance = structNew();

setCatId ( arguments.category_id );
setCatDesc ( arguments.cat_desc );
setCatShortDesc ( arguments.cat_short_desc );
setStatus ( arguments.status );

return this;

Call in the handler to save the bean:

// Populate a category bean var category = populateModel( categoryService.get( rc.id ) ); // validate it var vResults = validateModel( category );

// Check for errors
if( vResults.hasErrors() ){
// Show them and return to form
getPlugin(“MessageBox”).error( messageArray=vResults.getAllErrors() );
return editor( event,rc,prc );
} else {
getPlugin(“MessageBox”).info(“Category created”);
setNextEvent(“categories”);
}

I keep getting this error:

Error Type: coldbox.system.validation.IValidationManager : [N/A]
Error Messages: The value returned from the getValidationManager function is not of type coldbox.system.validation.IValidationManager.
If the component name is specified as a return type, its possible that a definition file for the component cannot be found or is not accessible.

Any ideas as to what could be causing it?

If you extend the IValidation does it work?

On the bean? Or the service?

Not sure, having a quick look in how they actually work, but that message usually means the name being returned from that method is not correct.

Which line is in the stack trace?

I mean handler not service, guessing you meant the bean

Yeah wherever the error is showing, what is that line returning?

Looks like line 126 in FrameworkSupertype.cfc

That is the final point, where are you calling validateModel?

In the save method, var vResults = validateModel( category );

Are you using your own validator, or just going with the standards?

I am using the built in standard one.

Thats what I thought, I can’t seem to see anything that is wrong. Just as a curiosity what if you dump the category and abort before the validateModel?

I am guessing that the category being returned might be a null object, this would confirm that but not sure if it is the fix though.

I get a category object with the variables in the variables.instance scope.

Could it have something to do with that?

Dont think so, as the error message is more about the wrong object being returned, as nothing looks wrong maybe this is a bug on ColdFusion 8 maybe.

I think Luis might need to jump in here…

I might have a bit of a play later tonight.

Ok cool. I was wondering, in the mean time are there any plugins for validation that you could suggest?

There is hyrule, but I am not sure how up to date it is, it is what I have used in the past.

Thanks! I’ll have to give it a go then :slight_smile:

Still looking to use the builtIn if possible. But for some reason the controller’s validationManager is not set. I did some digging and it keeps coming back as an empty string, so of course it isn’t of the type specified.

I see that the default in the instance.validationManager is a blank string in coldbox.system.web.Controller but there is a setValidationManager method that should be called and set it as the default somewhere it would seem like.

Any ideas?

Where is the bean located? Which folder…

I am thinking that it hasn’t been wired in, if it is not already drop the bean in your model folder, and reinit the application, and see how you go. Bit of a long shot, but worth a shot.

It is in the model/ folder already.