Maximum length
Another issue we might have is people inserting extremely long team names. To prevent this, we can set a max
attribute:
both/schemas/teams.js
Teams.attachSchema(new SimpleSchema({
name: {
type: String,
index: true,
unique: true,
max: 30
},
ownerId: {
type: String
},
gameIds: {
type: [String],
optional: true
}
}));
And again test it in the console:
Teams.insert({name: 'A really really really really really long name', ownerId: Meteor.userId()})
Our error should once again appear: insert failed: Error: Name cannot exceed 30 characters
.