#NEWLINE# def min_max( field , validator_class ) : #NEWLINE# #INDENT# "\n    Returns maximum minimum and minimum maximum value for given validator class\n    of given field.\n\n    :param field: WTForms Field object\n    :param validator_class: WTForms Validator class\n\n    Example::\n\n\n        class MyForm(Form):\n            some_integer_field = IntegerField(\n                validators=[Length(min=3, max=6), Length(min=4, max=7)]\n            )\n\n        form = MyForm()\n\n        min_max(form.some_integer_field, Length)\n        # {'min': 4, 'max': 6}\n    " #NEWLINE# min_values = [ ] #NEWLINE# max_values = [ ] #NEWLINE# for validator in field . validators : #NEWLINE# #INDENT# if isinstance ( validator , validator_class ) : #NEWLINE# #INDENT# if ( validator . min is not None ) : #NEWLINE# #INDENT# min_values . append ( validator . min ) #NEWLINE# #UNINDENT# if ( validator . max is not None ) : #NEWLINE# #INDENT# max_values . append ( validator . max ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if min_values : #NEWLINE# #INDENT# data [ 'min' ] = max ( min_values ) #NEWLINE# #UNINDENT# if min_values : #NEWLINE# #INDENT# data [ 'max' ] = min ( max_values ) #NEWLINE# #UNINDENT# return data