25 lines
		
	
	
		
			544 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			544 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| module Validators
 | |
|   class DeployEnv::StackTemplate < Base
 | |
| 
 | |
|     def valid?
 | |
|       return true unless @model.stack_template
 | |
| 
 | |
|       available_stack_templates.detect do |template|
 | |
|         template['id'] == @model.stack_template
 | |
|       end
 | |
|     end
 | |
| 
 | |
|     def message
 | |
|       "Invalid stack template '#{@model.stack_template}'."
 | |
|     end
 | |
| 
 | |
|     private
 | |
| 
 | |
|     def available_stack_templates
 | |
|       # map to hash to simplify mocks. Later replace this method with something more suitable
 | |
|       Devops::Db.connector.stack_templates.map(&:to_hash)
 | |
|     end
 | |
| 
 | |
|   end
 | |
| end
 |