From e5d12f9f3f1cd6560319e6b17bb8dcdca26c2ae0 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 24 May 2022 20:06:58 +0300 Subject: [PATCH] Update validate.js --- scripts/db/validate.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/db/validate.js b/scripts/db/validate.js index 5ba487be..7ff179fd 100644 --- a/scripts/db/validate.js +++ b/scripts/db/validate.js @@ -147,6 +147,28 @@ function findDuplicatesById(rows) { return errors } +// function findDuplicatesByName(rows) { +// rows = rows.map(row => { +// row.name = row.name.toLowerCase() + +// return row +// }) + +// const errors = [] +// const schema = Joi.array().unique((a, b) => a.name === b.name) +// const { error } = schema.validate(rows, { abortEarly: false }) +// if (error) { +// error.details.forEach(detail => { +// errors.push({ +// line: detail.context.pos + 2, +// message: `entry with the name "${detail.context.value.name}" already exists` +// }) +// }) +// } + +// return errors +// } + function validateChannelCategories(row, i) { const errors = [] row.categories.forEach(category => {