@@ -155,18 +155,7 @@ def get_max_len_of_var_char(field_info: Dict) -> int:
155155 return field_info .get ("params" , {}).get (k , v )
156156
157157
158- def check_str_arr (str_arr : Any , max_len : int ):
159- for s in str_arr :
160- if not isinstance (s , str ):
161- raise ParamError (message = f"expect string input, got: { type (s )} " )
162- if len (s ) > max_len :
163- raise ParamError (
164- message = f"invalid input, length of string exceeds max length. "
165- f"length: { len (s )} , max length: { max_len } "
166- )
167-
168-
169- def convert_to_str_array (orig_str_arr : Any , field_info : Any , check : bool = True ):
158+ def convert_to_str_array (orig_str_arr : Any , field_info : Dict , check : bool = True ):
170159 arr = []
171160 if Config .EncodeProtocol .lower () != "utf-8" .lower ():
172161 for s in orig_str_arr :
@@ -175,7 +164,16 @@ def convert_to_str_array(orig_str_arr: Any, field_info: Any, check: bool = True)
175164 arr = orig_str_arr
176165 max_len = int (get_max_len_of_var_char (field_info ))
177166 if check :
178- check_str_arr (arr , max_len )
167+ for s in arr :
168+ if not isinstance (s , str ):
169+ raise ParamError (
170+ message = f"field ({ field_info ['name' ]} ) expect string input, got: { type (s )} "
171+ )
172+ if len (s ) > max_len :
173+ raise ParamError (
174+ message = f"invalid input of field ({ field_info ['name' ]} ), "
175+ f"length of string exceeds max length. length: { len (s )} , max length: { max_len } "
176+ )
179177 return arr
180178
181179
0 commit comments