require "commands/image"
module Validators
  class Image::ImageInFilter < Base

    include ImageCommands

    def valid?
      available_images.map{|i| i["id"]}.include?(@model.id)
    end

    def message
      "Invalid image id '#{@model.id}' for provider '#{@model.provider}', please check image filters"
    end

    private

    def available_images
      get_available_provider_images(::Devops::Db.connector, @model.provider)
    end
  end
end
