require_relative "base"

module Validators
  module FieldValidator
    class Vpc < Base

      def valid?
        provider = ::Provider.get_conector(@model.provider, @model.provider_account)
        vpcs = provider.describe_vpcs
        ids = vpcs.map{|v| v["vpc_id"]}
        ids.include?(@value)
      rescue
        raise "Invalid provider account '#{@model.provider_account}'"
      end

      def message
        "Invalid vpc '#{@value}'."
      end
    end
  end
end

