From ca6281e2a686b2aabeb750fa84dcbbace7a18326 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Fri, 1 Jun 2018 19:39:43 +0300 Subject: [PATCH] length validations --- models/Todo.js | 2 ++ models/TodoList.js | 2 ++ models/User.js | 2 ++ 3 files changed, 6 insertions(+) diff --git a/models/Todo.js b/models/Todo.js index 860a870..7b92f3a 100644 --- a/models/Todo.js +++ b/models/Todo.js @@ -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 }, diff --git a/models/TodoList.js b/models/TodoList.js index 7c5abcd..fa551f6 100644 --- a/models/TodoList.js +++ b/models/TodoList.js @@ -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 }, diff --git a/models/User.js b/models/User.js index c8f9ccd..81b2c93 100644 --- a/models/User.js +++ b/models/User.js @@ -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' }],