繁体   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