def validators(self): max_length = self.object.field_data.get('max_length') max_words = self.object.field_data.get('max_words') validators = [] if max_length: validators.append(Length(max=max_length)) if max_words: validators.append(WordCount(max=max_words)) return validators
def _get_description_validators(self, description_settings, invited=False): validators = [] if description_settings['is_required'] and not invited: validators.append(DataRequired()) if description_settings['max_length']: validators.append(SoftLength(max=description_settings['max_length'])) if description_settings['max_words']: validators.append(WordCount(max=description_settings['max_words'])) return validators