lib/redis-model-extension/validation.rb
def valid_alias_key? alias_name, args = {}
      raise ArgumentError, "Unknown dynamic alias, use: #{redis_alias_config.keys.join(", ")}" unless redis_alias_config.has_key?(alias_name.to_sym)

      #normalize input hash of arguments
      args = HashWithIndifferentAccess.new(args)

      config = redis_alias_config[alias_name.to_sym]


      # use all specified keys
      config[:main_fields].each do |key|
        return false unless valid_item_for_redis_key? args, key
      end

      # is dynamic alias?
        if config[:order_field] && config[:args_field]
        #check if input arguments has order field
        if args.has_key?(config[:order_field]) && args[config[:order_field]] && args.has_key?(config[:args_field]) && args[config[:args_field]]
          #use filed order from defined field in args
          args[config[:order_field]].each do |key|
            return false unless valid_item_for_redis_key? args[config[:args_field]], key
          end
        else 
          return false
        end
      end

      return true
    end
def valid_alias_key? alias_name, args = {}
      raise ArgumentError, "Unknown dynamic alias, use: #{redis_alias_config.keys.join(", ")}" unless redis_alias_config.has_key?(alias_name.to_sym)

      #normalize input hash of arguments
      args = HashWithIndifferentAccess.new(args)

      config = redis_alias_config[alias_name.to_sym]


      # use all specified keys
      config[:main_fields].each do |key|
        return false unless valid_item_for_redis_key? args, key
      end

      # is dynamic alias?
        if config[:order_field] && config[:args_field]
        #check if input arguments has order field
        if args.has_key?(config[:order_field]) && args[config[:order_field]] && args.has_key?(config[:args_field]) && args[config[:args_field]]
          #use filed order from defined field in args
          args[config[:order_field]].each do |key|
            return false unless valid_item_for_redis_key? args[config[:args_field]], key
          end
        else 
          return false
        end
      end

      return true
    end
Validates if key by alias name and arguments is valid
 (all needed fields are not nil!)