| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  | require_relative "base" | 
					
						
							|  |  |  | module Validators | 
					
						
							|  |  |  |   module FieldValidator | 
					
						
							|  |  |  |     class Name < Base | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       MAX_NAME_LEN = 200
 | 
					
						
							| 
									
										
										
										
											2015-12-01 17:16:11 +03:00
										 |  |  |       NAME_REGEX = /\A[\w\-]{1,#{MAX_NAME_LEN}}\z/ | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |       def valid? | 
					
						
							|  |  |  |         !NAME_REGEX.match(@value).nil? | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def message | 
					
						
							| 
									
										
										
										
											2015-12-01 17:16:11 +03:00
										 |  |  |         "Invalid value '#{@value}': it should contains symbols 'a-zA-Z0-9_-' and length should be more then 1 and less or equals then #{MAX_NAME_LEN} symbols" | 
					
						
							| 
									
										
										
										
											2015-10-06 13:50:26 +03:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |