2013-11-28 3 views
0

Доброе утро люди. Вот моя проблема:Geddy не может прочитать «проверки» собственности

Im new to Node.js, и я решил попробовать Geddy Framework, так как кажется довольно надежным. Итак, я следую this tutorial. Когда я добавляю некоторые валидации в модель ToDo, это вызывает у меня ошибку, и я не могу запустить сервер.

Любая помощь приветствуется.

Вот код:

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); 

Вот выход консоли

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. 

В окончательной информации. Im с использованием Windows 7. У меня есть node.js v0.10.22 и Geddy v0.11.8

ответ

0

У вас есть двойной «t».

this.defineProperties({ 
    tittle: {type: 'string', required: true}, //this should be title 
    status: {type: 'string', required:true}, // and this comma should be deleted 
}); 
+0

Большое спасибо, да, эти жесткие ошибки sintax не используются, потому что IDE пометила их для меня (на других языках): 3 –

Смежные вопросы