2 * Copyright © 2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 export const getValidationsError = dataRows => {
20 const groupBy = dataRows.reduce((result, value, key) => {
21 const groupKey = value.name.toLowerCase();
24 if (result.hasOwnProperty(groupKey)) {
25 result[groupKey].push(key);
27 result[groupKey] = [key];
33 error.alreadyExists = Object.keys(groupBy).reduce((result, value) => {
34 if (groupBy[value].length > 1) {
35 result = [...result, ...groupBy[value]];
41 error.emptyName = dataRows.reduce((result, value, key) => {
42 const name = value.name;
51 error.invalidCharacters = dataRows.reduce((result, value, key) => {
52 const groupKey = value.name;
55 if (!/^[\w\s\d]+$/.test(groupKey)) {