2727 'type' ,
2828 'min' ,
2929 'max' ,
30+ 'max_length' ,
3031 'constant' ,
3132 '_values_provider' ,
3233 'values' ,
@@ -71,6 +72,7 @@ def _reload(self):
7172 self .required = read_bool_from_config ('required' , config , default = False )
7273 self .min = config .get ('min' )
7374 self .max = config .get ('max' )
75+ self .max_length = config .get ('max_length' )
7476 self .secure = read_bool_from_config ('secure' , config , default = False )
7577 self .separator = config .get ('separator' , ',' )
7678 self .multiple_arguments = read_bool_from_config ('multiple_arguments' , config , default = False )
@@ -277,6 +279,9 @@ def validate_value(self, value, *, ignore_required=False):
277279 return None
278280
279281 if self .type == 'text' :
282+ if (not is_empty (self .max_length )) and (len (value ) > int (self .max_length )):
283+ return 'is longer than allowed char length (' \
284+ + str (len (value )) + ' > ' + str (self .max_length ) + ')'
280285 return None
281286
282287 if self .type == 'file_upload' :
@@ -291,7 +296,7 @@ def validate_value(self, value, *, ignore_required=False):
291296 int_value = int (value )
292297
293298 if (not is_empty (self .max )) and (int_value > int (self .max )):
294- return 'is greater than allowed value (' \
299+ return 'is longer than allowed value (' \
295300 + value_string + ' > ' + str (self .max ) + ')'
296301
297302 if (not is_empty (self .min )) and (int_value < int (self .min )):
0 commit comments