Good morning people. Here's my problem:
Im new to Node.js and i decided to try the Geddy Framework, as it seems pretty robust. So, i'm following this tutorial. When i add some validations to the ToDo model, it throws me an error and i cannot start the server.
Any help is welcome.
Here the code:
var ToDo = function () {
this.defineProperties({
tittle: {type: 'string', required: true},
status: {type: 'string', required:true},
});
this.validatesPresent('title');
this.validatesLength('title', {min: 5});
this.validatesWithFunction('status', function (status) {
return status == 'open' || status == 'done';
}, {message: "Status must be 'open' or 'done.'"});
};
ToDo = geddy.model.register('ToDo', ToDo);
Here is the console output
C:\Users\rvela\Documents\NodejsProjects\to_do>geddy
[Thu, 28 Nov 2013 16:16:56 GMT] INFO Server starting with config: {
"environment": "development",
"workers": 1,
"port": 4000,
"spdy": null,
"ssl": null,
"detailedErrors": true,
"flash": {
"defaultClass": "alert",
"inlineClasses": {
"success": "alert alert-success",
"alert": "alert",
"error": "alert alert-error",
"info": "alert alert-info"
},
"blockClasses": {
"success": "alert alert-block alert-success",
"alert": "alert alert-block",
"error": "alert alert-block alert-error",
"info": "alert alert-block alert-info"
}
},
"debug": true,
"rotateWorkers": false,
"rotationWindow": 7200000,
"rotationTimeout": 300000,
"logDir": "C:\\Users\\rvela\\Documents\\NodejsProjects\\to_do\\log",
"gracefulShutdownTimeout": 30000,
"heartbeatInterval": 5000,
"heartbeatWindow": 20000,
"staticFilePath": "C:\\Users\\rvela\\Documents\\NodejsProjects\\to_do\\public",
"cacheControl": {
"expires": {
"default": 0
}
},
"sessions": {
"store": "memory",
"key": "sid",
"expiry": 1209600
},
"cookieSessionKey": "sdata",
"i18n": {
"defaultLocale": "en-us",
"loadPaths": [
"C:\\Users\\rvela\\Documents\\NodejsProjects\\to_do\\config\\locales"
]
},
"hostname": null,
"fullHostname": null,
"connectCompatibility": false,
"model": {
"defaultAdapter": "filesystem"
}
}
[Thu, 28 Nov 2013 16:16:56 GMT] INFO Creating 1 worker process.
C:\Users\rvela\AppData\Roaming\npm\node_modules\geddy\node_modules\model\lib\index.js:1182
reg[this.name].properties[name].validations[condition] =
^
TypeError: Cannot read property 'validations' of undefined
at validates (C:\Users\rvela\AppData\Roaming\npm\node_modules\geddy\node_modules\model\lib\index.js:1182:36)
at null.validatesPresent (C:\Users\rvela\AppData\Roaming\npm\node_modules\geddy\node_modules\model\lib\index.js:1137:33)
at ToDo (C:\Users\rvela\Documents\NodejsProjects\to_do\app\models\to_do.js:9:10)
at Object.utils.mixin.registerDefinition (C:\Users\rvela\AppData\Roaming\npm\node_modules\geddy\node_modules\model\lib\index.js:835:15)
at Object.utils.mixin.register (C:\Users\rvela\AppData\Roaming\npm\node_modules\geddy\node_modules\model\lib\index.js:822:17)
at Object.<anonymous> (C:\Users\rvela\Documents\NodejsProjects\to_do\app\models\to_do.js:18:20)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
[Thu, 28 Nov 2013 16:16:57 GMT] ERROR Worker 8640 died.
As final info. Im using Windows 7. I have node.js v0.10.22 and Geddy v0.11.8
You have a double "t".
this.defineProperties({
tittle: {type: 'string', required: true}, //this should be title
status: {type: 'string', required:true}, // and this comma should be deleted
});