Sha256: e1f83277030688f796341d63ba295cef7acfedd4e2e90d355e6e6de125d4c4d6
Contents?: true
Size: 1.24 KB
Versions: 14
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true class Serega module SeregaPlugins module Metadata class MetaAttribute # # Validator for meta_attribute :path parameter # class CheckPath # Regexp for valid path FORMAT = /\A[\w~-]+\z/ private_constant :FORMAT class << self # # Checks allowed characters. # Allowed characters: "a-z", "A-Z", "0-9", "_", "-", "~". # # @param path [Array<String, Symbol>] Metadata attribute path names # # @raise [SeregaError] when metadata attribute name has invalid format # @return [void] # def call(path) path.each { |attr_name| check_name(attr_name) } end private def check_name(name) name = name.to_s raise SeregaError, message(name) unless FORMAT.match?(name) end def message(name) <<~MESSAGE.tr("\n", "") Invalid metadata path #{name.inspect}. Allowed characters: "a-z", "A-Z", "0-9", "_", "-", "~" MESSAGE end end end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems