diff --git a/const.js b/const.js index 99d91ea..48ae886 100644 --- a/const.js +++ b/const.js @@ -1,6 +1,9 @@ // categories need to be lowercase strings const PROTOCOL_CATEGORIES = ['money market', 'yield strategy', 'liquid locker', 'others']; +const DESCRIPTION_MAXIMUM_CHARACTERS = 120; + module.exports = { PROTOCOL_CATEGORIES, + DESCRIPTION_MAXIMUM_CHARACTERS, } \ No newline at end of file diff --git a/validate-config.js b/validate-config.js index 2e3ea17..f95e7bf 100644 --- a/validate-config.js +++ b/validate-config.js @@ -1,7 +1,7 @@ const fs = require('fs'); const path = require('path'); const yaml = require('js-yaml'); -const {PROTOCOL_CATEGORIES} = require("./const"); +const {PROTOCOL_CATEGORIES, DESCRIPTION_MAXIMUM_CHARACTERS} = require("./const"); const LIMIT_ICON_KB_SIZE = 20; const BUFFER_LIMIT_ICON_KB_SIZE = LIMIT_ICON_KB_SIZE + 1; @@ -22,6 +22,18 @@ function validateCategory(protocol, category) { } } +function validateDescription(info) { + const {protocol, field, index, description} = info; + + if (!mustBeNonEmptyString(description)) { + throw new Error(`protocol ${protocol}: metadata ${field} invalid 'description' field at index ${index}`); + } + + if (description.length > DESCRIPTION_MAXIMUM_CHARACTERS) { + throw new Error(`protocol ${protocol}: metadata ${field} 'description' too long at index ${index}`); + } +} + async function main() { const CHANGED_PROTOCOLS = process.env.CHANGED_PROTOCOLS; const GET_ASSET_LIST_URL = process.env.GET_ASSET_LIST_URL; @@ -157,9 +169,7 @@ function checkMetadataField(data, protocol, field, assetMap) { throw new Error(`protocol ${protocol}: metadata ${field} address not found in pendle ${field} list at index ${index}`); } - if (!mustBeNonEmptyString(description)) { - throw new Error(`protocol ${protocol}: metadata ${field} invalid 'description' field at index ${index}`); - } + validateDescription({protocol, field, index, description}); if (!mustBeNonEmptyString(integrationUrl)) { throw new Error(`protocol ${protocol}: metadata ${field} invalid 'integrationUrl' field at index ${index}`);