1
我剛剛開始使用Meteor和autoform。我創建了quickform調用的Schema。問題是我無法弄清楚如何驗證在沒有數組組包裝的特定數組索引上工作。我可以驗證它,如果我在下面使用這種類型的模式,但它然後它需要一個對象,我正在尋找一個字符串。如果將類型更改爲字符串,則驗證完全不顯示。任何幫助是極大的讚賞。電子郵件中的流星Collection2驗證顯示爲對象但不是字符串
schema.js
Schema.NewUser = new SimpleSchema({
"profile.organization" : {
type: String,
regEx: /^[a-z0-9A-z .]{3,30}$/,
optional: true,
label: "Company"
},
emails: {
type: Object,
label: "Email",
},
"emails.$":{
type: Object,
},
"emails.$.address": {
type: String,
label: "Email",
regEx: SimpleSchema.RegEx.Email,
},
parent: {
type: String,
optional: true,
},
roles: {
type: Array,
optional: true
},
'roles.$': {
type: String,
allowedValues: [
'owner',
'admin'
],
optional: true,
label: "Choose a number",
autoform: {
options: [
{
label: "owner",
value: "owner"
},
{
label: "admin",
value: "admin"
}
]
}
}
});
HTML
{{> quickForm collection="Meteor.users" id="insertUserForm" type="method" meteormethod="insertUser" schema="Schema.NewUser" fields="profile.organization, emails.0.address, roles.0" }}
您期待哪個字段的驗證發生? –
我想要email.0.address進行驗證。我想顯示它作爲一個單獨的領域沒有框和加減號。如果我顯示電子郵件驗證工作,但是如果我執行email.0.address,它只會顯示在控制檯中。謝謝您的幫助 –