@@ -70,7 +70,7 @@ def valid_flag_sets(method, flag_sets)
7070 log_invalid_flag_set_type ( method )
7171 elsif flag_set . is_a? ( String ) && flag_set . empty?
7272 log_invalid_flag_set_type ( method )
73- elsif !flag_set . empty? && string_match? ( flag_set . strip . downcase , method , Flagset_regex , log_invalid_match )
73+ elsif !flag_set . empty? && string_match? ( flag_set . strip . downcase , method , Flagset_regex , : log_invalid_match)
7474 valid_flag_sets . add ( flag_set . strip . downcase )
7575 else
7676 log_invalid_flag_set_type ( method )
@@ -79,6 +79,46 @@ def valid_flag_sets(method, flag_sets)
7979 !valid_flag_sets . empty? ? valid_flag_sets . to_a . sort : [ ]
8080 end
8181
82+ def validate_fallback_treatment ( method , fallback_treatment )
83+ if !fallback_treatment . is_a? Engine ::Models ::FallbackTreatment
84+ @config . logger . warn ( "#{ method } : Fallback treatment instance should be FallbackTreatment, input is discarded" )
85+ return false
86+ end
87+
88+ if !fallback_treatment . treatment . is_a? String
89+ @config . logger . warn ( "#{ method } : Fallback treatment value should be str type, input is discarded" )
90+ return false
91+ end
92+
93+ return false unless string_match? ( fallback_treatment . treatment , method , Fallback_treatment_regex , :log_invalid_fallback_treatment )
94+
95+ if fallback_treatment . treatment . size > Fallback_treatment_size
96+ @config . logger . warn ( "#{ method } : Fallback treatment size should not exceed #{ Fallback_treatment_size } characters" )
97+ return false
98+ end
99+
100+ true
101+ end
102+
103+ def valid_split_name? ( method , split_name )
104+ if split_name . nil?
105+ log_nil ( :split_name , method )
106+ return false
107+ end
108+
109+ unless string? ( split_name )
110+ log_invalid_type ( :split_name , method )
111+ return false
112+ end
113+
114+ if empty_string? ( split_name )
115+ log_empty_string ( :split_name , method )
116+ return false
117+ end
118+
119+ true
120+ end
121+
82122 private
83123
84124 def string? ( value )
@@ -95,7 +135,7 @@ def number_or_string?(value)
95135
96136 def string_match? ( value , method , regex_exp , log_if_invalid )
97137 if regex_exp . match ( value ) == nil
98- log_if_invalid ( value , method )
138+ method ( log_if_invalid ) . call ( value , method )
99139 false
100140 else
101141 true
@@ -134,25 +174,6 @@ def log_key_too_long(key, method)
134174 @config . logger . error ( "#{ method } : #{ key } is too long - must be #{ @config . max_key_size } characters or less" )
135175 end
136176
137- def valid_split_name? ( method , split_name )
138- if split_name . nil?
139- log_nil ( :split_name , method )
140- return false
141- end
142-
143- unless string? ( split_name )
144- log_invalid_type ( :split_name , method )
145- return false
146- end
147-
148- if empty_string? ( split_name )
149- log_empty_string ( :split_name , method )
150- return false
151- end
152-
153- true
154- end
155-
156177 def valid_key? ( method , key )
157178 if key . nil?
158179 log_nil ( :key , method )
@@ -329,29 +350,8 @@ def valid_properties?(properties)
329350 true
330351 end
331352
332- def validate_fallback_treatment ( method , fallback_treatment )
333- if !fallback_treatment . is_a? Engine ::Models ::FallbackTreatment
334- @config . logger . warn ( "#{ method } : Fallback treatment instance should be FallbackTreatment, input is discarded" )
335- return false
336- end
337-
338- if !fallback_treatment . treatment . is_a? String
339- @config . logger . warn ( "#{ method } : Fallback treatment value should be str type, input is discarded" )
340- return false
341- end
342-
343- return false unless string_match? ( fallback_treatment . treatment , method , Fallback_treatment_regex )
344-
345- if fallback_treatment . treatment . size > Fallback_treatment_size
346- @config . logger . warn ( "#{ method } : Fallback treatment size should not exceed %s characters" , Fallback_treatment_size )
347- return false
348- end
349-
350- true
351- end
352-
353353 def log_invalid_fallback_treatment ( key , method )
354- @config . logger . warn ( "#{ method } : Invalid treatment #{ key } , Fallback treatment should match regex %s" , Fallback_treatment_regex )
354+ @config . logger . warn ( "#{ method } : Invalid treatment #{ key } , Fallback treatment should match regex #{ Fallback_treatment_regex } " )
355355 end
356356 end
357357end
0 commit comments