Class: Uploadcare::Internal::FileTagNormalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/uploadcare/internal/file_tag_normalizer.rb

Overview

Normalizes and validates file tags before sending them to Uploadcare.

Constant Summary collapse

MAX_LENGTH =
100
MAX_COUNT =
50
VALID_PATTERN =
/\A[a-z0-9._-]+\z/

Class Method Summary collapse

Class Method Details

.call(tags, max_count: MAX_COUNT) ⇒ Array<String>

Normalize a list of file tags.

Tags are stripped, lowercased, and deduplicated while preserving their first-seen order.

Parameters:

  • tags (Array<String>)
  • max_count (Integer, nil) (defaults to: MAX_COUNT)

    Maximum number of tags; nil disables the limit

Returns:

  • (Array<String>)

Raises:

  • (ArgumentError)

    if a tag is invalid



19
20
21
22
23
24
25
# File 'lib/uploadcare/internal/file_tag_normalizer.rb', line 19

def call(tags, max_count: MAX_COUNT)
  raise ArgumentError, 'tags must be an array of strings' unless tags.is_a?(Array)

  normalized = normalize(tags)
  validate_count(normalized, max_count)
  normalized
end