Returns a cleaned and validated value. Raises a ValidationError
        if there's a problem
541897
def validate(self, value):
        
        if value is None:
            if self.required:
                raise ValidationError('{} - None values are not allowed'.format(self.column_name or self.db_field))
        return value
458421
def clean(self, value):
        """"""

        if isinstance(value, numbers.Number):
            return value
        elif isinstance(value, six.string_types):
            try:
                value = float(value)
                return int(value) if value.is_integer() else value
            except ValueError:
                raise ParameterNotValidError

        raise ParameterNotValidError
372160
def clean(self, value):
        """"""
        if value:
            value = value.replace('-', '').replace(' ', '')
            self.card_type = verify_credit_card(value)
            if self.card_type is None:
                raise forms.ValidationError("Invalid credit card number.")
        return value
1164151
def full_clean(self, exclude, validate_unique=False):
        

        # validate against neomodel
        try:
            self.deflate(self.__properties__, self)
        except DeflateError as e:
            raise ValidationError({e.property_name: e.msg})
        except RequiredProperty as e:
            raise ValidationError({e.property_name: 'is required'})
1316320
def clean(self, value):
		

		# If the value is None and it's optional, return as is
		if value is None and self._optional:
			return None

		# Go through each of the nodes
		for i in range(len(self._nodes)):

			# If it's valid
			if self._nodes[i].valid(value):

				# Use it's clean
				return self._nodes[i].clean(value)

		# Something went wrong
		raise ValueError('value', value)
967622
def get_validated_object(self, value):
        
        try:
            if self.get_field_type().check_value(value) or self.get_field_type().can_use_value(value):
                data = self.get_field_type().use_value(value)
                self._prepare_child(data)
                return data
            else:
                return None
        except AttributeError:
            return value
1121130
def clean(self, value):
        """"""

        for parameter_obj in self.types:
            try:
                return parameter_obj.clean(value)
            except ParameterNotValidError:
                continue

        raise ParameterNotValidError
930772
def clean_value
      if (type == :string || type == :text) && !Axlsx::trust_input
        Axlsx::sanitize(::CGI.escapeHTML(@value.to_s))
      else
        @value.to_s
      end
    end
713871
def clean_honeypot(self):
        """"""
        value = self.cleaned_data["honeypot"]
        if value:
            raise forms.ValidationError(self.fields["honeypot"].label)
        return value
714921
def clean(self, value):
        """"""
        if (
            self.base_type is not None and
            value is not None and
            not isinstance(value, self.base_type)
        ):
            if isinstance(self.base_type, tuple):
                allowed_types = [typ.__name__ for typ in self.base_type]
                allowed_types_text = ' or '.join(allowed_types)
            else:
                allowed_types_text = self.base_type.__name__
            err_msg = 'Value must be of %s type.' % allowed_types_text
            raise ValidationError(err_msg)

        if not self.has_value(value):
            if self.default is not None:
                raise StopValidation(self.default)

            if self.required:
                raise ValidationError('This field is required.')
            else:
                raise StopValidation(self.blank_value)

        return value
224961
def __validate(self, target, value, oldvalue, initiator):
        
        if value == oldvalue:
            return value

        if self.allow_null and value is None:
            return value

        if self.check_value(value):
            return value
        else:
            if self.throw_exception:
                if self.message:
                    self.message = self.message.format(
                            field=self.field, new_value=value, old_value=oldvalue, key=initiator.key)
                    raise ValidateError(self.message)
                else:
                    raise ValidateError('Value %s from column %s is not valid' % (value, initiator.key))

            return oldvalue
567270
def _clean(self, value):
        """"""
        if value is None:
            return None
        elif self.type_ is None:
            return value
        elif self.check_type(value):
            return value
        elif self.is_type_castable:  # noqa
            return self.type_(value)

        error_fmt = "%s must be a %s, not a %s"
        error = error_fmt % (self.name, self.type_, type(value))
        raise TypeError(error)
853800
def validate(self):
        
        if getattr(self, '_getting_validated', False):
            return True
        self._getting_validated = True
        self._validation_error_tuples = []
        self._non_validation_error = None
        try:
            for val in itervalues(self._class_validators):
                try:
                    if isinstance(val.func, string_types):
                        valid = getattr(self, val.func)()
                    else:
                        valid = val.func(self)
                    if valid is False:
                        raise utils.ValidationError(
                            'Validation failed', None, None, self
                        )
                except utils.ValidationError as val_err:
                    self._validation_error_tuples += val_err.error_tuples
                except GENERIC_ERRORS as err:
                    if not self._non_validation_error:
                        self._non_validation_error = err
            if self._validation_error_tuples:
                self._error_hook(self._validation_error_tuples)
                msgs = ['Validation failed:']
                msgs += [val.message for val in self._validation_error_tuples]
                raise utils.ValidationError(
                    message='\n- '.join(msgs),
                    _error_tuples=self._validation_error_tuples,
                )
            if self._non_validation_error:
                raise self._non_validation_error                               #pylint: disable=raising-bad-type
            return True
        finally:
            self._getting_validated = False
            self._validation_error_tuples = None
            self._non_validation_error = None
962068
def clean(self, value):
        
        if not value:
            raise ValidationError(
                'Error found in Form Field: Nothing to validate')

        data = dict((bf.name, value[i]) for i, bf in enumerate(self.form))
        self.form = form = self.form.__class__(data)
        if not form.is_valid():
            error_dict = list(form.errors.items())
            raise ValidationError([
                ValidationError(mark_safe('{} {}'.format(
                    k.title(), v)), code=k) for k, v in error_dict])

        # This call will ensure compress is called as expected.
        return super(FormField, self).clean(value)
1366440
def clean(self, value):
        
        value = super().clean(value)
        if value in (None, ''):
            value = ''
        value = smart_text(value)
        if value == '':
            return value
        valid_values = []
        for group_label, group in self.choices:
            valid_values += [str(k) for k, v in group]
        if value not in valid_values:
            raise ValidationError(gettext('Select a valid choice. That choice is not one of the available choices.'))
        return value
111084
def clean(self, value):
        

        obj = self.factory.create(value)

        # todo: what if the field defines properties that have any of
        # these names:
        if obj:
            del obj.fields
            del obj.alias
            del obj.validators
            del obj.required
            del obj.factory

        # do own cleaning first...
        self._validate_existence(obj)
        self._run_validators(obj)

        # ret = {}
        # for name in self.fields.keys():
        #     ret[name] = getattr(obj, name)
        # return ret
        return obj
309306
def validate(self, value, redis):
        '''
        
        '''
        # cleanup
        if type(value) == str:
            value = value.strip()

        value = self.value_or_default(value)

        # validation
        self.validate_required(value)

        if self.regex and not re.match(self.regex, value, flags=re.ASCII):
            raise InvalidFieldError(self.name)

        if self.forbidden and value in self.forbidden:
            raise ReservedFieldError(self.name)

        if self.allowed and value not in self.allowed:
            raise InvalidFieldError(self.name)

        if self.index:
            key = self.key()

            old = debyte_string(redis.hget(key, value))
            old_value = getattr(self.obj, self.name)

            if old is not None and old != self.obj.id:
                raise NotUniqueFieldError(self.name)
            elif old_value != value:
                self.obj._old[self.name] = old_value

        return value