mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-11 02:30:21 +08:00
[*] Allow zero elements in the replyTo field
This commit is contained in:
parent
6a51036e48
commit
017e22c88d
1 changed files with 5 additions and 5 deletions
|
@ -6,11 +6,11 @@ const SendingUtils = require('../local-api/sending-utils');
|
||||||
|
|
||||||
const SNIPPET_LENGTH = 191;
|
const SNIPPET_LENGTH = 191;
|
||||||
|
|
||||||
const getValidateArrayLength1 = (fieldName) => {
|
const getValidateArrayLength = (fieldName, min, max) => {
|
||||||
return (stringifiedArr) => {
|
return (stringifiedArr) => {
|
||||||
const arr = JSON.parse(stringifiedArr);
|
const arr = JSON.parse(stringifiedArr);
|
||||||
if (arr.length !== 1) {
|
if ((arr.length < min) || (arr.length > max)) {
|
||||||
throw new Error(`Value for ${fieldName} must have a length of 1. Value: ${stringifiedArr}`);
|
throw new Error(`Value for ${fieldName} must have a length in range [${min}-${max}]. Value: ${stringifiedArr}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,14 @@ module.exports = (sequelize, Sequelize) => {
|
||||||
processed: Sequelize.INTEGER,
|
processed: Sequelize.INTEGER,
|
||||||
to: buildJSONARRAYColumnOptions('to'),
|
to: buildJSONARRAYColumnOptions('to'),
|
||||||
from: Object.assign(buildJSONARRAYColumnOptions('from'), {
|
from: Object.assign(buildJSONARRAYColumnOptions('from'), {
|
||||||
|
validate: {validateArrayLength1: getValidateArrayLength('Message.from', 1, 1)},
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
validate: {validateArrayLength1: getValidateArrayLength1('Message.from')},
|
|
||||||
}),
|
}),
|
||||||
cc: buildJSONARRAYColumnOptions('cc'),
|
cc: buildJSONARRAYColumnOptions('cc'),
|
||||||
bcc: buildJSONARRAYColumnOptions('bcc'),
|
bcc: buildJSONARRAYColumnOptions('bcc'),
|
||||||
replyTo: Object.assign(buildJSONARRAYColumnOptions('replyTo'), {
|
replyTo: Object.assign(buildJSONARRAYColumnOptions('replyTo'), {
|
||||||
|
validate: {validateArrayLength1: getValidateArrayLength('Message.replyTo', 0, 1)},
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
validate: {validateArrayLength1: getValidateArrayLength1('Message.replyTo')},
|
|
||||||
}),
|
}),
|
||||||
inReplyTo: { type: Sequelize.STRING, allowNull: true},
|
inReplyTo: { type: Sequelize.STRING, allowNull: true},
|
||||||
references: buildJSONARRAYColumnOptions('references'),
|
references: buildJSONARRAYColumnOptions('references'),
|
||||||
|
|
Loading…
Reference in a new issue