length validations

This commit is contained in:
2018-06-01 19:39:43 +03:00
parent 9c354f5445
commit ca6281e2a6
3 changed files with 6 additions and 0 deletions

View File

@@ -6,6 +6,8 @@ const TodoSchema = Schema({
text: {
type: String,
required: true,
minLength: 1,
maxLength: 300,
},
list: { type: Schema.Types.ObjectId, ref: 'TodoList', required: true },
user: { type: Schema.Types.ObjectId, ref: 'User', required: true },

View File

@@ -6,6 +6,8 @@ const TodoListSchema = Schema({
name: {
type: String,
required: true,
minLength: 1,
maxLength: 100,
},
todos: [{ type: Schema.Types.ObjectId, ref: 'Todo' }],
user: { type: Schema.Types.ObjectId, ref: 'User', required: true },

View File

@@ -13,6 +13,8 @@ const UserSchema = Schema({
required: true,
unique: true,
validate: /^\S*$/,
minLength: 3,
maxLength: 50,
},
lists: [{ type: Schema.Types.ObjectId, ref: 'TodoList' }],
todos: [{ type: Schema.Types.ObjectId, ref: 'Todo' }],