Applies the validation criteria.
        Returns value, new value, or None if invalid.

        Overload this in derived classes.
355231
def validate(self, value):
        
        try:
            # trap blank fields here
            if not self.blank or value:
                v = int(value)
                if v < self.imin or v > self.imax:
                    return None
            return value
        except ValueError:
            return None
717686
def check(self):
        
        try:
            value = self.raw_value
        except (AttributeError, KeyError) as err:
            self._reraise_if_required(err)
        else:
            if self.checker:
                self.checker(self.full_name, value)
            try:
                self.validate(value)
                self.run_validators(value)
            except ValidationError as error:
                raise ValueError("Setting {} has an invalid value: {}".format(self.full_name, error))
206439
def validate(self, value, model_instance):
        
        if not isinstance(value, base.StateWrapper):
            raise exceptions.ValidationError(self.error_messages['wrong_type'] % value)
        elif not value.workflow == self.workflow:
            raise exceptions.ValidationError(self.error_messages['wrong_workflow'] % value.workflow)
        elif value.state not in self.workflow.states:
            raise exceptions.ValidationError(self.error_messages['invalid_state'] % value.state)
645864
def apply(self, collection, ops, **kwargs):
        """"""
        validator = lambda obj: all(op(obj, val) for (op, val) in ops)  # noqa
        return [o for o in collection if validator(o)]
365142
def _load(self, value: Any):
        

        if value in self.empty_values:
            # If a default has been set for the field return it
            if self.default is not None:
                default = self.default
                value = default() if callable(default) else default
                return value

            # If no default is set and this field is required
            elif self.required:
                self.fail('required')

            # In all other cases just return `None` as we do not want to
            # run validations against an empty value
            else:
                return None

        # If choices exist then validate that value is be one of the choices
        if self.choices:
            value_list = value
            if not isinstance(value, (list, tuple)):
                value_list = [value]
            for v in value_list:
                if v not in self.choice_dict:
                    self.fail(
                        'invalid_choice', value=v,
                        choices=list(self.choice_dict))

        # Cast and Validate the value for this Field
        value = self._cast_to_type(value)

        # Call the rest of the validators defined for this Field
        self._run_validators(value)

        return value
420185
def is_valid(self, attrs = None):
        
        if attrs is None:
            reason = {}
        else:
            reason = attrs
        valid = True
        for attr, validation in self.__class__.__validates__.items():
            if validation.__class__ == validators.validation:
                validation.name = attr
            if not validation(self):
                reason[attr] = getattr(self, attr)
                valid = False
        return valid
427612
def validate(cls, **kwargs):
        '''  '''
        # errors can store multiple errors
        # obj is an instance in case validation succeeds
        # redis is needed for database validation
        errors = ValidationErrors()
        obj = cls()
        redis = cls.get_redis()

        # Check the fields
        for fieldname, field in obj.proxy:
            if not field.fillable:
                value = field.default
            else:
                try:
                    value = field.validate(kwargs.get(fieldname), redis)
                except BadField as e:
                    errors.append(e)
                    continue

            setattr(
                obj,
                fieldname,
                value
            )

        # Check for custom validation rules
        for fieldname in dir(cls):
            rule = getattr(cls, fieldname)

            if hasattr(rule, '_is_validation_rule') and rule._is_validation_rule:
                try:
                    rule(obj)
                except BadField as e:
                    errors.append(e)

        # Trigger errors if any
        if errors.has_errors():
            raise errors

        # Return the object with the new data set
        return obj
1226496
def validate(self, instance, value):
        
        if not isinstance(value, (tuple, list, np.ndarray)):
            self.error(instance, value)
        if isinstance(value, (tuple, list)):
            for i, val in enumerate(value):
                if isinstance(val, string_types):
                    if val.upper() not in VECTOR_DIRECTIONS:
                        self.error(
                            instance=instance,
                            value=val,
                            extra='This is an invalid Vector3 representation.',
                        )
                    value[i] = VECTOR_DIRECTIONS[val.upper()]

        return super(Vector3Array, self).validate(instance, value)
837395
def validate(self, value):
        
        errors = []
        value = self._validate_type(value, errors)
        self._validate_value(value, errors)

        if errors:
            raise ValidationErrors(errors)

        return value
1308863
def validate(self, value):
        
        errors = []
        self._used_validator = []
        for val in self._validators:
            try:
                val.validate(value)
                self._used_validator.append(val)
            except ValidatorException as e:
                errors.append(e)
            except Exception as e:
                errors.append(ValidatorException("Unknown Error", e))
        if len(errors) > 0:
            raise ValidatorException.from_list(errors)
        return value
604707
def _validate(self, value):
        
        errors = []
        kwargs = {}
        for validator in self.validators:
            try:
                r = validator(value)
                if not isinstance(validator, Validator) and r is False:
                    self.fail('validator_failed')
            except ValidationError as err:
                kwargs.update(err.kwargs)
                if isinstance(err.messages, dict):
                    errors.append(err.messages)
                else:
                    errors.extend(err.messages)
        if errors:
            raise ValidationError(errors, **kwargs)
52065
def validate(self, value=None, model=None, context=None):
        
        errors = []
        for validator in self.validators:
            if value is None and not isinstance(validator, Required):
                continue

            error = validator.run(
                value=value,
                model=model,
                context=context if self.use_context else None
            )
            if error:
                errors.append(error)

        return errors
612644
def validate(self, instance, value):
        
        if not self.coerce and not isinstance(value, self._class_container):
            self.error(instance, value)
        if self.coerce and not isinstance(value, CONTAINERS):
            value = [value]
        if not isinstance(value, self._class_container):
            out_class = self._class_container
        else:
            out_class = value.__class__
        out = []
        for val in value:
            try:
                out += [self.prop.validate(instance, val)]
            except ValueError:
                self.error(instance, val, extra='This item is invalid.')
        return out_class(out)
816248
def validate(context = Attributor::DEFAULT_ROOT_CONTEXT)
      raise AttributorException, 'validation conflict' if @validating
      @validating = true

      context = [context] if context.is_a? ::String
      keys_with_values = []
      errors = []

      self.class.attributes.each do |sub_attribute_name, sub_attribute|
        sub_context = self.class.generate_subcontext(context, sub_attribute_name)

        value = __send__(sub_attribute_name)
        keys_with_values << sub_attribute_name unless value.nil?

        if value.respond_to?(:validating) # really, it's a thing with sub-attributes
          next if value.validating
        end

        errors.concat sub_attribute.validate(value, sub_context)
      end
      self.class.requirements.each do |req|
        validation_errors = req.validate(keys_with_values, context)
        errors.concat(validation_errors) unless validation_errors.empty?
      end

      errors
    ensure
      @validating = false
    end
922537
def _call_to_base_type(self, value):
    
    methods = self._find_methods('_validate', '_to_base_type')
    call = self._apply_list(methods)
    return call(value)
226948
def _validate(self, val):
        
        if self.allow_None and val is None:
            return
        super(Range, self)._validate(val)

        self._checkBounds(val)
481755
def validate(self):
        
        super(BoolFilter, self).validate()

        self._value = truth(str(self._value), self._condition)
        self._condition = "yes" if self._value else "no"