Validate field **IN** string or list.

        Args:
            filter_value (string | list): A string or list of values.

        Returns:
            (boolean): Results of check
543005
def _in(field, filter_value):
        
        valid = False
        if field in filter_value:
            valid = True
        return valid
1194202
def validate(self):
        
        val = self._condition.lower()
        if val and val[0] in "+-":
            val = val[1:]

        matcher = PatternFilter
        if not val or val.startswith('/') and val.endswith('/'):
            pass
        elif val.replace('.', '0').isdigit():
            matcher = FloatFilter
        elif self._condition in (TRUE | FALSE):
            matcher = BoolFilter
        elif any(val.endswith(i) for i in ByteSizeFilter.UNITS) and val[:-1].isdigit():
            matcher = ByteSizeFilter
        elif TimeFilter.TIMEDELTA_RE.match(val):
            matcher = TimeFilter

        self._inner = matcher(self._name, self._condition)
657145
def validate(self, value):
        
        value = super(Boolean, self).validate(value)

        if value is not None:
            value = bool(value)

        return value
494836
def validate(self, input_string):
        
        validation_result = False
        try:
            validation_result = bool(match(pattern=self.pattern, string=input_string))
        except TypeError as e:
            self.log.error(
                'Exception while validating Regex, pattern={}, input_string={} - exception: {}'.format(self.pattern,
                                                                                                       input_string,
                                                                                                       e))
        return validation_result
1068067
def _match(self, p, value):
        
        if self._is_operator(p):
            return self._match_operator(p, value)
        else:
            try:
                if self._is_value_filter(p):
                    return self._match_value_filter(p, value)
                else:
                    return self._match_key_filter(p, value)
            except KeyError:
                if self._suppress_key_errors or self._suppress_exceptions:
                    return False
                else:
                    raise
            except TypeError:
                if self._suppress_exceptions:
                    return False
                else:
                    raise
969071
def where(self, fieldname, value, negate=False):
        
        if negate:
            return self.mask([elem != value
                              for elem in self[fieldname]])
        else:
            return self.mask([elem == value
                              for elem in self[fieldname]])
1097216
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 we are validating an ANY field, immediately return true
		if self._type == 'any':
			pass

		# If we are validating a DATE, DATETIME, IP or TIME data point
		elif self._type in ['base64', 'date', 'datetime', 'ip', 'md5', 'time', 'uuid']:

			# If it's a date or datetime type and the value is a python type
			if self._type == 'date' and isinstance(value, (datetime.date, datetime.datetime)):
				value = value.strftime('%Y-%m-%d')

			elif self._type == 'datetime' and isinstance(value, (datetime.date, datetime.datetime)):
				if isinstance(value, datetime.datetime):
					value = value.strftime('%Y-%m-%d %H:%M:%S')
				elif isinstance(value, datetime.date):
					value = '%s 00:00:00' % value.strftime('%Y-%m-%d')

			# If it's a time type and the value is a python type
			elif self._type == 'time' and isinstance(value, (datetime.time, datetime.datetime)):
				value = value.strftime('%H:%M:%S')

			# Else if the type is md5 and the value is a python type
			elif self._type == 'md5' and isinstance(value, _MD5_TYPE):
				value = value.hexdigest()

			# If the value is not a string
			elif not isinstance(value, basestring):
				self.validation_failures.append(('.'.join(level), 'not a string'))
				return False

			# If there's no match
			if not _typeToRegex[self._type].match(value):
				self.validation_failures.append(('.'.join(level), 'failed regex (internal)'))
				return False

			# If we are checking an IP
			if self._type == 'ip':

				# If there's a min or a max
				if self._minimum is not None or self._maximum is not None:

					# If the IP is greater than the maximum
					if self._maximum is not None and self.__compare_ips(value, self._maximum) == 1:
						self.validation_failures.append(('.'.join(level), 'exceeds maximum'))
						return False

					# If the IP is less than the minimum
					if self._minimum is not None and self.__compare_ips(value, self._minimum) == -1:
						self.validation_failures.append(('.'.join(level), 'did not meet minimum'))
						return False

					# Return OK
					return True

		# Else if we are validating some sort of integer
		elif self._type in ['int', 'timestamp', 'uint']:

			# If the type is a bool, fail immediately
			if type(value) == bool:
				self.validation_failures.append(('.'.join(level), 'is a bool'))
				return False

			# If it's not an int
			if not isinstance(value, (int, long)):

				# And it's a valid representation of an int
				if isinstance(value, basestring) \
					and _typeToRegex['int'].match(value):

					# If it starts with 0
					if value[0] == '0' and len(value) > 1:

						# If it's followed by X or x, it's hex
						if value[1] in ['x', 'X'] and len(value) > 2:
							value = int(value, 16)

						# Else it's octal
						else:
							value = int(value, 8)

					# Else it's base 10
					else:
						value = int(value)

				# Else, return false
				else:
					self.validation_failures.append(('.'.join(level), 'not an integer'))
					return False

			# If it's not signed
			if self._type in ['timestamp', 'uint']:

				# If the value is below 0
				if value < 0:
					self.validation_failures.append(('.'.join(level), 'signed'))
					return False

		# Else if we are validating a bool
		elif self._type == 'bool':

			# If it's already a bool
			if isinstance(value, bool):
				return True

			# If it's an int or long at 0 or 1
			if isinstance(value, (int, long)) and value in [0, 1]:
				return True

			# Else if it's a string
			elif isinstance(value, basestring):

				# If it's t, T, 1, f, F, or 0
				if value in ['true', 'True', 'TRUE', 't', 'T', '1', 'false', 'False', 'FALSE', 'f', 'F', '0']:
					return True
				else:
					self.validation_failures.append(('.'.join(level), 'not a valid string representation of a bool'))
					return False

			# Else it's no valid type
			else:
				self.validation_failures.append(('.'.join(level), 'not valid bool replacement'))
				return False

		# Else if we are validating a decimal value
		elif self._type == 'decimal':

			# If the type is a bool, fail immediately
			if type(value) == bool:
				self.validation_failures.append(('.'.join(level), 'is a bool'))
				return False

			# If it's already a Decimal
			if isinstance(value, Decimal):
				pass

			# Else if we fail to convert the value
			else:
				try: value = Decimal(value)
				except (DecimalInvalid, TypeError, ValueError):
					self.validation_failures.append(('.'.join(level), 'can not be converted to decimal'))
					return False

		# Else if we are validating a floating point value
		elif self._type == 'float':

			# If the type is a bool, fail immediately
			if type(value) == bool:
				self.validation_failures.append(('.'.join(level), 'is a bool'))
				return False

			# If it's already a float
			if isinstance(value, float):
				pass

			# Else if we fail to convert the value
			else:
				try: value = float(value)
				except (ValueError, TypeError):
					self.validation_failures.append(('.'.join(level), 'can not be converted to float'))
					return False

		# Else if we are validating a JSON string
		elif self._type == 'json':

			# If it's already a string
			if isinstance(value, basestring):

				# Try to decode it
				try:
					value = JSON.decode(value)
					return True
				except ValueError:
					self.validation_failures.append(('.'.join(level), 'Can not be decoded from JSON'))
					return False

			# Else
			else:

				# Try to encode it
				try:
					value = JSON.encode(value)
					return True
				except (ValueError, TypeError):
					self.validation_failures.append(('.'.join(level), 'Can not be encoded to JSON'))
					return False

		# Else if we are validating a price value
		elif self._type == 'price':

			# If the type is a bool, fail immediately
			if type(value) == bool:
				self.validation_failures.append(('.'.join(level), 'is a bool'))
				return False

			# If it's not a floating point value
			if not isinstance(value, Decimal):

				# But it is a valid string representing a price, or a float
				if isinstance(value, (basestring, float)) \
					and _typeToRegex['price'].match(str(value)):

					# Convert it to a decimal
					value = Decimal(value).quantize(Decimal('1.00'))

				# Else if it's an int
				elif isinstance(value, int):

					# Convert it to decimal
					value = Decimal(str(value) + '.00')

				# Else whatever it is is no good
				else:
					self.validation_failures.append(('.'.join(level), 'failed regex (internal)'))
					return False

			# Else
			else:

				# If the exponent is longer than 2
				if abs(value.as_tuple().exponent) > 2:
					self.validation_failures.append(('.'.join(level), 'too many decimal points'))
					return False

		# Else if we are validating a string value
		elif self._type == 'string':

			# If the value is not some form of string
			if not isinstance(value, basestring):
				self.validation_failures.append(('.'.join(level), 'is not a string'))
				return False

			# If we have a regex
			if self._regex:

				# If it doesn't match the regex
				if re.match(self._regex, value) == None:
					self.validation_failures.append(('.'.join(level), 'failed regex (custom)'))
					return False

			# Else
			elif self._minimum or self._maximum:

				# If there's a minimum length and we don't reach it
				if self._minimum and len(value) < self._minimum:
					self.validation_failures.append(('.'.join(level), 'not long enough'))
					return False

				# If there's a maximum length and we surpass it
				if self._maximum and len(value) > self._maximum:
					self.validation_failures.append(('.'.join(level), 'too long'))
					return False

				# Return OK
				return True

		# If there's a list of options
		if self._options is not None:

			# Returns based on the option's existance
			if value not in self._options:
				self.validation_failures.append(('.'.join(level), 'not in options'))
				return False
			else:
				return True

		# Else check for basic min/max
		else:

			# If the value is less than the minimum
			if self._minimum and value < self._minimum:
				self.validation_failures.append(('.'.join(level), 'did not meet minimum'))
				return False

			# If the value is greater than the maximum
			if self._maximum and value > self._maximum:
				self.validation_failures.append(('.'.join(level), 'exceeds maximum'))
				return False

		# Value has no issues
		return True
561148
def filter_not_empty_values(value):
    """"""
    if not value:
        return None
    data = [x for x in value if x]
    if not data:
        return None
    return data
530326
def _validate_filter_fields(self, filter_by):
        
        for filter_field in filter_by:
            if (
                filter_field not in self.RESPONSE_FIELD_MAP
                or not self.RESPONSE_FIELD_MAP[filter_field].is_filter
            ):
                raise InvalidFilterFieldException(
                    '"{0}" is an invalid filter field'.format(filter_field)
                )
362046
def validate(self, value):
        
        for validate in self.validates:
            value = validate(value)
        return value
1000071
def _validate(self, p):
        
        if self._is_operator(p):
            for operator_or_filter in (p[1] if p[0] != '!' else [p[1]]):
                if p[0] == '^':
                    self._validate_xor_args(p)
                self._validate(operator_or_filter)
        elif not self._is_value_filter(p) and not self._is_key_filter(p):
            raise ValueError('Not a valid operator or filter - {0}'.format(p))
1184102
def ensure_true(bool_func: Callable[[Any], bool],
                message=None) -> Filter_T:
    

    def validate(value):
        if bool_func(value) is not True:
            _raise_failure(message)
        return value

    return validate
567369
def validate(self, value):
        
        if not isinstance(value, (list, tuple)) or isinstance(value, str_types):
            self.raise_error('Only lists and tuples may be used in the ListField vs provided {0}'
                             .format(type(value).__name__))
        super(ListField, self).validate(value)
878606
def validate_value(self, value):
        
        field = self.instance.preference.setup_field()
        value = field.to_python(value)
        field.validate(value)
        field.run_validators(value)
        return value
979348
def is_valid(value, valid_values):
        

        valid = False

        if isinstance(valid_values, type) and type(value) is valid_values:
            valid = True
        elif isinstance(valid_values, type) and valid_values == float and type(value) == int:
            #special case to allow ints as float inputs
            valid = True
        elif isinstance(value, dict) and isinstance(valid_values, dict):
            # check that all values actually exist in valid_values
            # assert value.keys() & valid_values.keys() == value.keys() # python 3 syntax
            assert set(value.keys()) & set(valid_values.keys()) == set(value.keys()) # python 2
            # valid = True
            for k ,v in value.items():
                valid = Parameter.is_valid(v, valid_values[k])
                if valid ==False:
                    break

        elif isinstance(value, dict) and valid_values == Parameter:
            valid = True

        elif isinstance(valid_values, list) and value in valid_values:
            valid = True

        return valid
918623
def _validate_condition_keys(self, field, value, error):
        
        if 'field' in value:
            operators = self.nonscalar_conditions + self.scalar_conditions
            matches = sum(1 for k in operators if k in value)
            if matches == 0:
                error(field, 'Must contain one of {}'.format(operators))
                return False
            elif matches > 1:
                error(
                    field,
                    'Must contain no more than one of {}'.format(operators)
                )
                return False
            return True
        elif 'and' in value:
            for condition in value['and']:
                self._validate_condition_keys(field, condition, error)
        elif 'or' in value:
            for condition in value['or']:
                self._validate_condition_keys(field, condition, error)
        else:
            error(field, "Must contain field + operator keys, 'and', or 'or'.")
            return False
586998
def get_value_filter(self, filter_value):
        '''
        
        '''
        self.validate_parameter(filter_value)
        f, t = self._ranges[filter_value]
        limits = {}
        # lt and gte to ensure non-overlapping ranges
        if f is not None:
            limits['gte'] = f
        if t is not None:
            limits['lt'] = t

        return Q('range', **{
            self._params['field']: limits
        })