1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-22 14:49:43 +02:00

Add validation to background field

This commit is contained in:
Maksim Eltyshev 2020-06-03 22:27:20 +05:00
parent ab83d7c9ab
commit 99d9ab4a9e
10 changed files with 130 additions and 25 deletions

View file

@ -15,9 +15,35 @@ module.exports = {
type: 'string',
isNotEmptyString: true,
},
// TODO: add validation
background: {
type: 'json',
custom: (value) => {
if (_.isNull(value)) {
return true;
}
if (!_.isPlainObject(value)) {
return false;
}
if (!Project.BACKGROUND_TYPES.includes(value.type)) {
return false;
}
if (
value.type === 'gradient' &&
_.size(value) === 2 &&
Project.BACKGROUND_GRADIENTS.includes(value.name)
) {
return true;
}
if (value.type === 'image' && _.size(value) === 1) {
return true;
}
return false;
},
},
backgroundImage: {
type: 'json',