require "commands/image"

module Validators
  class DeployEnv::Image < Base
    include ::ImageCommands

    def valid?
      return true unless @model.image
      get_available_provider_images(::Devops::Db.connector, @model.provider).detect do |image|
        image["id"] == @model.image
      end
    end

    def message
      "Invalid image '#{@model.image}'."
    end
  end
end
