2
我使用的collection2包這裏看到的每一次驗證失敗每次聲稱「需要電子郵件」時,驗證都會失敗。我對Meteor.users模式
我的架構:
Schema.UserProfile = new SimpleSchema({
firstName: {
type: String,
regEx: /^[a-zA-Z-]{2,25}$/,
optional: true
},
lastName: {
type: String,
regEx: /^[a-zA-Z]{2,25}$/,
optional: true
},
birthday: {
type: Date,
optional: true
},
likes: {
type: [String],
optional: true
}
})
Schema.User = new SimpleSchema({
username: {
type: String,
regEx: /^[a-z0-9A-Z_]{3,15}$/,
optional: true
},
email: {
type: String,
regEx: SimpleSchema.RegEx.Email
},
verified: {
type: Boolean,
optional: true
},
createdAt: {
type: Date,
optional: true
},
profile: {
type: Schema.UserProfile,
optional: true
},
services: {
type: Object,
optional: true,
blackbox: true
}
})
我把它像這樣:
Meteor.users.attachSchema(Schema.User)
而只是爲了檢查我硬編碼的值增加用戶與完美的罰款電子郵件地址:
Accounts.createUser({email: "[email protected]"})
但是當我運行這個時,返回一個很大的異常,除其他事項外:
Exception while invoking method 'registerUser` Error: Email is required
at getErrorObject
<packages/aldeed:collection2/collection2.js:369:1>
Sanitized and reported to the client as: Email is required [400]
我錯過了什麼?
然後呢我輸入'Accounts.createUser'?編輯:沒關係,我不需要改變任何東西。謝謝! – Yeats
@Yeats和以前一樣。 'createUser'變換和(我相信,也)驗證傳遞給它的對象。查看[文檔以獲取更多信息](http://docs.meteor.com/#/full/accounts_createuser) – Kriegslustig