diff --git a/src/models/Idea.js b/src/models/Idea.js index 5709a65e..fc2edcbc 100644 --- a/src/models/Idea.js +++ b/src/models/Idea.js @@ -210,7 +210,7 @@ module.exports = function (db, sequelize, DataTypes) { validate: { textLength(value) { // We need to undo the sanitization before we can check the length - let len = htmlToText.fromString(value).length; + let len = htmlToText.fromString(value || '').length; let summaryMinLength = (this.config && this.config.ideas && @@ -231,7 +231,7 @@ module.exports = function (db, sequelize, DataTypes) { }, }, set: function (text) { - text = text ? sanitize.summary(text.trim()) : null; + text = text ? sanitize.summary(text.trim()) : ''; this.setDataValue('summary', text); }, }, @@ -241,7 +241,7 @@ module.exports = function (db, sequelize, DataTypes) { allowNull: !this.publishDate, validate: { textLength(value) { - let len = sanitize.summary(value.trim()).length; + let len = sanitize.summary(value || ''.trim()).length; let descriptionMinLength = (this.config && this.config.ideas && @@ -263,7 +263,7 @@ module.exports = function (db, sequelize, DataTypes) { }, }, set: function (text) { - text = text ? sanitize.content(text.trim()) : null; + text = text ? sanitize.content(text.trim()) : ''; this.setDataValue('description', text); }, }, @@ -318,7 +318,7 @@ module.exports = function (db, sequelize, DataTypes) { }, allowNull: true, set: function (text) { - text = text ? sanitize.content(text.trim()) : null; + text = text ? sanitize.content(text.trim()) : ''; this.setDataValue('modBreak', text); }, },