| 
									
										
										
										
											2016-02-24 14:33:02 +03:00
										 |  |  | require 'exceptions/non_existing_user' | 
					
						
							| 
									
										
										
										
											2015-09-22 12:49:27 +03:00
										 |  |  | module Validators | 
					
						
							|  |  |  |   class Helpers::Users < Base | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-24 14:33:02 +03:00
										 |  |  |     error_class ::Devops::NonExistingUser | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-22 12:49:27 +03:00
										 |  |  |     def valid? | 
					
						
							| 
									
										
										
										
											2016-01-20 17:47:07 +03:00
										 |  |  |       available_users = ::Devops::Db.connector.users_names(@model) | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  |       @nonexistent_users = (@model || []) - available_users | 
					
						
							| 
									
										
										
										
											2015-09-22 12:49:27 +03:00
										 |  |  |       @nonexistent_users.empty? | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def message | 
					
						
							|  |  |  |       Devops::Messages.t("project.deploy_env.validation.users.not_exist", users: @nonexistent_users.join("', '")) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |