I have model User.cfc is code snnipet is here ```/...
# box-products
r
I have model User.cfc is code snnipet is here
Copy code
/**
 * I model a API/User
 */
component  table="users" persistent="true" extends="cborm.models.ActiveEntity" transientCache="false"
 delegates="Validatable@cbvalidation,Population@cbDelegates,Auth@cbSecurity,Authorizable@cbSecurity,JwtSubject@cbSecurity"{

	// get reference
	property name="validationManager" inject="ValidationManager@cbvalidation";

	// Properties
	property name="id" column="id" fieldType="id" generator="uuid";
	property name="username" ormtype="string";
	property name="email" ormtype="string";
	property name="mobile" ormtype="string";
	property name="firstname" ormtype="string";
	property name="lastname" ormtype="string";
	property name="country" ormtype="string";
	property name="password" ormtype="string";
	property name="is_email_verify" ormtype="BOOLEAN";
	property name="is_phone_verify" ormtype="BOOLEAN";
	property name="is_seller_verify" ormtype="BOOLEAN";
	property name="role" cfc="wallpaper_id" fieldtype="one-to-one" fkcolumn="users_wall" lazy="true" notnull="false";
	property name="profile_photo" ormtype="string";
	property name="profile_banner" ormtype="string";
	property name="role" cfc="subscription_id" fieldtype="one-to-one" fkcolumn="user_subsc_id" lazy="true" notnull="false";
	property name="created_at" ormtype="TIMESTAMP";
	property name="active" ormtype="BOOLEAN";
	property name="otp" ormtype="string";
	

	// Validation Constraints
	this.constraints = {
		username = { required=true},
		email = { required=true, type="email" },
		mobile = { required=true, size="5..10" },
		firstname = { required=true, size="5..10" },
		lastname = { required=true },
		// password = { required=true, min="8" max="24" type="string" };
	};

	// Constraint Profiles
	this.constraintProfiles = {
		// "update" : {}
	};

	// Population Control
	this.population = {
		include : ['*'],
		exclude : [ "password" ]
	};

	// Mementifier
	this.memento = {
		// An array of the properties/relationships to include by default
		defaultIncludes = [ "*" ],
		// An array of properties/relationships to exclude by default
		defaultExcludes = [],
		// An array of properties/relationships to NEVER include
		neverInclude = [],
		// A struct of defaults for properties/relationships if they are null
		defaults = {},
		// A struct of mapping functions for properties/relationships that can transform them
		mappers = {  }
	};

	/**
	 * Constructor
	 */
	User function init(){
		super.init( useQueryCaching="false" );
		return this;
	}

	/**
	 * Verify if the model has been loaded from the database
	 */
	function isLoaded(){
		return ( !isNull( variables.id ) && len( variables.id ) );
	}


}
and the handler code is here
Copy code
/**
 * I am a new handler
 * Implicit Functions: preHandler, postHandler, aroundHandler, onMissingAction, onError, onInvalidHTTPMethod
 */
component extends="coldbox.system.RestHandler"{

	this.prehandler_only 	= "";
	this.prehandler_except 	= "";
	this.posthandler_only 	= "";
	this.posthandler_except = "";
	this.aroundHandler_only = "";
	this.aroundHandler_except = "";
	this.allowedMethods = {};

	property name="userService" inject="API.User";
	property name="bCrypt" inject="BCrypt@BCrypt";
	
	property name="queryBuilder" inject="QueryBuilder@qb";
	

	/**
	 * Display a listing of the resource
	 */
	function register( event, rc, prc ){
		var userData = {
			id: createUUID(),
            username : rc.username ,
            email  : rc.email,
            mobile  : rc.mobile,
            firstname  : rc.firstname,
            lastname   : rc.lastname,
            country   : rc.country,
            password     : bCrypt.hashPassword(rc.password),
            is_email_verify     : 0,
            is_phone_verify     : 0,
            is_seller_verify     : 0,
            wallpaper_id     : "",
            profile_photo     : "",
            profile_banner     : "",
			subscription_id: 1,
			otp : '1234',
            created_at : now(),			
            active : 1	
        };
		prc.user = userService
        .new(userData);
		prc.newUser = userService
		.save( prc.user )
		.getMemento(excludes="[password,otp]" );
			
		event.getResponse()
		.setData( prc.user )
		.addMessage(
			"user registration completed...!"
		);

	}

}
when i'am calling register method iam getting bellow error says
An exception ocurred: Can't cast Component [ValidationManager] to String
Copy code
{
  "data": {
    "environment": {
      "currentRoutedUrl": "api/register/",
      "timestamp": "2023-07-25T07:40:06Z",
      "currentRoute": "api/register/",
      "currentEvent": "API.Auth.register"
    },
    "exception": {
      "stack": [
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\modules\\cborm\\models\\BaseORMService.cfc:1540",
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\modules\\cborm\\models\\BaseORMService.cfc:1977",
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\modules\\cborm\\models\\BaseORMService.cfc:1555",
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\modules\\cborm\\models\\ActiveEntity.cfc:85",
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\handlers\\API\\Auth.cfc:48",
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\coldbox\\system\\RestHandler.cfc:58",
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\coldbox\\system\\web\\Controller.cfc:998",
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\coldbox\\system\\web\\Controller.cfc:713",
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\coldbox\\system\\Bootstrap.cfc:290",
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\coldbox\\system\\Bootstrap.cfc:506",
        "E:\\LiveProjects\\Coldfusion\\Stackur\\StackurApi\\Application.cfc:115"
      ],
      "detail": "",
      "type": "expression",
      "extendedInfo": ""
    }
  },
  "error": true,
  "pagination": {
    "totalPages": 1,
    "maxRows": 0,
    "offset": 0,
    "page": 1,
    "totalRecords": 0
  },
  "messages": "An exception ocurred: Can't cast Component [ValidationManager] to String"
}
a
Please use threads and text snippets for large blocks of code. Looking at your code the only thing that looks odd is
.getMemento(excludes="[password,otp]" );
That should either be an array...
.getMemento(excludes=["password","otp"] );
or a list...
.getMemento(excludes="password,otp" );
you seem to have invalid mix of both data types
I can't see a reference to your handler in the stack trace though so are you sure that's where the error is?
r
According to me it says
An exception ocurred: Can't cast Component [ValidationManager] to String
on the mesage key and when i dump
prc.user = userService.new(userData);
writeDump(prc.user);
i seen the property and on the property i found
ValidationManager
as a
component
so i don't think this error comes with that if that then it will return a syntax error but now i changed
getMemento
as array as you said, after taht this gives me the same error
a
why are you dumping out the object, try dumping out the getMemento value - but exclude the
validationManager
- why would you want that in your memento?
r
no i don't want. Actually what happens when the this code is excuted
prc.newUser = userService
.save( prc.user )
.getMemento(excludes="password,otp" );
writeDump(prc.newUser)
the error comes when i want to save the data using model.
a
OK - need to find what is causing the error. Split up your method chaining until you've narrowed down the cause else we are chasing shadows.
r
Ok, i'll try as possible thanks @aliaspooryorik
I want to use s3 bucket in my coldbox project can you help me little bit, i don't have any idea bacause i'am not used s3 before my any project
a
Solve one problem at a time 🙂
r
ok, I understand 👍
a
When you've got current stuff done then there is a ColdBox module you can use https://www.forgebox.io/view/s3sdk
r
Ok I'll try after my current stuff Thanks