簡體   English   中英

Geddy無法讀取屬性“驗證”

[英]Geddy cannot read property 'validations'

大家早上好。 這是我的問題:

我是Node.js的新手,因此我決定嘗試Geddy框架,因為它看起來很健壯。 因此,我正在關注本教程 當我向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.

作為最終信息。 我正在使用Windows7。我有node.js v0.10.22和Geddy v0.11.8

您有一個雙“ t”。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM