Valid

		Checks if a value is valid based on the instance's values

		Arguments:
			value {mixed} -- The value to validate

		Returns:
			bool
183240
def valid(self, value, level=[]):
		

		# Reset validation failures
		self.validation_failures = []

		# If the value is None and it's optional, we're good
		if value is None and self._optional:
			return True

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

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

				# Return OK
				return True

		# Not valid for anything
		self.validation_failures.append(('.'.join(level), 'no valid option'))
		return False
362046
def validate(self, value):
        
        for validate in self.validates:
            value = validate(value)
        return value
831478
def validate(self, value, messages=None):
        
        valid     = True
        primitive = value

        def log(msg):
            if messages is not None:
                messages.append(msg)

        if self.enum:
            if value not in self.enum.keys():
                valid = False
                args  = (self.name, str(value))
                log("%s value '%s' not in allowed enumerated values." % args)
            else:
                primitive = int(self.enum[value])

        if self.type:
            if self.type.validate(primitive, messages, self.name) is False:
                valid = False

        if self.range:
            if primitive < self.range[0] or primitive > self.range[1]:
                valid = False
                args  = (self.name, str(primitive), self.range[0], self.range[1])
                log("%s value '%s' out of range [%d, %d]." % args)

        return valid
1065987
def validate_values(func, dic):
    
    for value_name, value in dic.items():
        if not func(value):
            raise ValueError('{} can not be {}'.format(value_name, value))
113645
def _ensure_value_is_valid(self, value):
        """"""
        if not isinstance(value, self.__class__.value_type):
            raise TypeError('{0} is not valid collection value, instance '
                            'of {1} required'.format(
                                value, self.__class__.value_type))
        return value
758014
def valid?
      valid = true

      rules.each_pair do |field, rules|
        if ! @obj.respond_to?(field)
          raise InvalidKey, "cannot validate non-existent field '#{field}'"
        end

        rules.each do |r|
          if ! r.valid_value?(@obj.send(field))
            valid = false
            errors[field] = {:rule => r.error_key, :params => r.params}
            break
          end
        end
      end

      @valid = valid
    end
702957
def valid_level(value):
    """"""
    value = value.upper()
    if getattr(logging, value, None) is None:
        raise argparse.ArgumentTypeError("%s is not a valid level" % value)
    return value
440099
def assert_valid(self, instance, value=None):
        
        if value is None:
            value = instance._get(self.name)
        if (
                value is not None and
                not self.equal(value, self.validate(instance, value))
        ):
            message = 'Invalid value for property: {}: {}'.format(
                self.name, value
            )
            raise ValidationError(message, 'invalid', self.name, instance)
        return True
671808
def validate_range_value(value):
    
    if value == (None, None):
        return

    if not hasattr(value, '__iter__'):
        raise TypeError('Range value must be an iterable, got "%s".' % value)
    if not 2 == len(value):
        raise ValueError('Range value must consist of two elements, got %d.' %
                         len(value))
    if not all(isinstance(x, (int,float)) for x in value):
        raise TypeError('Range value must consist of two numbers, got "%s" '
                        'and "%s" instead.' % value)
    if not value[0] <= value[1]:
        raise ValueError('Range must consist of min and max values (min <= '
                         'max) but got "%s" and "%s" instead.' % value)
    return
1342984
def validate(self, value):
        
        if value == '':
            if self.kwargs.get('nullable', __nullable__):
                value = None
            else:
                value = 0
            
        if not isinstance(value, Model):
            return super(ReferenceProperty, self).validate(value)

        if not value.is_saved():
            raise BadValueError(
                    '%s instance must be saved before it can be stored as a '
                    'reference' % self.reference_class.__class__.__name__)
        if not isinstance(value, self.reference_class):
            raise KindError('Property %s must be an instance of %s' %
                    (self.name, self.reference_class.__class__.__name__))

        return value
1358546
def _validate(self, value):
    
    if not isinstance(value, self._enum_type):
      raise TypeError('Expected a %s instance, got %r instead' %
                      (self._enum_type.__name__, value))
671548
def checkValue(self,value,strict=0):
        
        v = self._coerceValue(value,strict)
        return self.checkOneValue(v,strict)
1355984
def assert_valid(self, instance, value=None):
        """"""
        valid = super(Dictionary, self).assert_valid(instance, value)
        if not valid:
            return False
        if value is None:
            value = instance._get(self.name)
        if value is None:
            return True
        if self.key_prop or self.value_prop:
            for key, val in iteritems(value):
                if self.key_prop:
                    self.key_prop.assert_valid(instance, key)
                if self.value_prop:
                    self.value_prop.assert_valid(instance, val)
        return True
735414
def validate(self, values):
        
        if not self.schema or (values is None and not self.schema.get('required', False)):
            return
        self.validator.validate(values)
302136
def valid(self, value, level=[]):
		

		# Reset validation failures
		self.validation_failures = []

		# If the value is None and it's optional, we're good
		if value is None and self._optional:
			return True

		# If the value isn't a dictionary
		if not isinstance(value, dict):
			self.validation_failures.append(('.'.join(level), str(value)))
			return False

		# Init the return, assume valid
		bRet = True

		# Go through each node in the instance
		for k in self._nodes:

			# Add the field to the level
			lLevel = level[:]
			lLevel.append(k)

			# If we are missing a node
			if k not in value:

				# If the value is not optional
				if not self._nodes[k]._optional:
					self.validation_failures.append(('.'.join(lLevel), 'missing'))
					bRet = False

				# Continue to next node
				continue

			# If the element isn't valid, return false
			if not self._nodes[k].valid(value[k], lLevel):
				self.validation_failures.extend(self._nodes[k].validation_failures)
				bRet = False
				continue

			# If the element requires others
			if k in self._requires:

				# Go through each required field
				for f in self._requires[k]:

					# If the field doesn't exist in the value
					if f not in value or value[f] in ('0000-00-00','',None):
						self.validation_failures.append(('.'.join(lLevel), 'requires \'%s\' to also be set' % str(f)))
						bRet = False

		# Return whatever the result was
		return bRet
114112
def validate(self, value):
        
        try:
            # trap blank fields here
            if not self.blank or value:
                float(value)
            return value
        except ValueError:
            return None
94634
def is_valid(self, name, value):
        
        if name not in self.header_types:
            return False
        t = self.header_types[name]
        if t == ATTR_TYPE_DISCRETE:
            return isinstance(value, int)
        elif t == ATTR_TYPE_CONTINUOUS:
            return isinstance(value, (float, Decimal))
        return True