function validateAllTags()

in source/lambda/lib/validations.ts [207:245]


function validateAllTags(listTags: string[], tags: string[]) {
  if (EMPTY_TYPES.includes(listTags) && EMPTY_TYPES.includes(tags)) {
    throw new LambdaError({
      message: 'Tags are missing. At least one of these should have at least one tag: listTags, tags.',
      name: 'ValidationError',
      statusCode: 400
    });
  }

  if (!EMPTY_TYPES.includes(listTags) && !Array.isArray(listTags)) {
    throw new LambdaError({
      message: `"listTags" is invalid from the connection definition. It should be a string array.`,
      name: 'ValidationError',
      statusCode: 400
    });
  }

  if (!EMPTY_TYPES.includes(tags) && !Array.isArray(tags)) {
    throw new LambdaError({
      message: `"tags" is invalid from the connection definition. It should be a string array.`,
      name: 'ValidationError',
      statusCode: 400
    });
  }

  const listTagsLength = listTags ? listTags.length : 0;
  const tagsLength = tags ? tags.length : 0;

  if (listTagsLength + tagsLength === 0) {
    throw new LambdaError({
      message: `Both "listTags" and "tags" are empty. At least one of them should have at least one tag.`,
      name: 'ValidationError',
      statusCode: 400
    });
  }

  if (listTagsLength > 0) validateTags(listTags, 'listTags');
  if (tagsLength > 0) validateTags(tags, 'tags');
}