1from flex.error_messages import MESSAGES 2from flex.exceptions import ValidationError 3from flex.constants import ( 4 INTEGER, 5 STRING, 6) 7from flex.utils import pluralize 8from flex.validation.common import ( 9 generate_object_validator, 10) 11from flex.decorators import ( 12 pull_keys_from_obj, 13 suffix_reserved_words, 14 skip_if_any_kwargs_empty, 15) 16 17 18@pull_keys_from_obj('type', 'minLength') 19@suffix_reserved_words 20@skip_if_any_kwargs_empty('type_', 'minLength') 21def validate_type_for_min_length(type_, minLength, **kwargs): 22 types = pluralize(type_) 23 24 if not set(types).intersection((STRING,)): 25 raise ValidationError( 26 MESSAGES['type']['invalid_type_for_min_length'], 27 ) 28 29 30min_length_schema = { 31 'type': INTEGER, 32 'minimum': 0, 33} 34min_length_validator = generate_object_validator( 35 schema=min_length_schema, 36) 37