23 lines
		
	
	
		
			482 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			482 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require_relative "base"
 | |
| 
 | |
| module Validators
 | |
|   module FieldValidator
 | |
|     class Vpc < Base
 | |
| 
 | |
|       def valid?
 | |
|         provider = ::Provider::ProviderFactory.get(@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
 | |
| 
 | 
