Checks if a given value is of a specific type

        :param value: the value to check
        :param data_type: the type to be checked upon
        :return:
10202
def check_value_and_type(value, data_type):
        
        if value is not None and data_type is not type(None):
            # if not isinstance(value, data_type):
            if not type_inherits_of_type(data_type, type(value)):
                raise TypeError(
                    "Value: '{0}' is not of data type: '{1}', value type: {2}".format(value, data_type, type(value)))
26303
def check(self, topic, value):
        
        datatype_key = topic.meta.get('datatype', 'none')
        self._datatypes[datatype_key].check(topic, value)
        validate_dt = topic.meta.get('validate', None)
        if validate_dt:
            self._datatypes[validate_dt].check(topic, value)
331151
def has_value_of_type(self, var_type):
        
        if self.has_value() and self.has_type(var_type):
            return True
        return False
843915
private boolean isDatatype( DdlTokenStream tokens,
                                int type ) throws ParsingException {
        // Loop through the registered statement start string arrays and look for exact matches.

        switch (type) {
            case DataTypes.DTYPE_CODE_CHAR_STRING: {
                for (String[] stmts : basicCharStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_NCHAR_STRING: {
                for (String[] stmts : basicNationalCharStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_BIT_STRING: {
                for (String[] stmts : basicBitStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_EXACT_NUMERIC: {
                for (String[] stmts : basicExactNumericTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_APROX_NUMERIC: {
                for (String[] stmts : basicApproxNumericStringTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_DATE_TIME: {
                for (String[] stmts : basicDateTimeTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
            case DataTypes.DTYPE_CODE_MISC: {
                for (String[] stmts : basicMiscTypes) {
                    if (tokens.matches(stmts)) return true;
                }
            }
                break;
        }

        return false;
    }
1088304
def _is_valid_datatype(datatype_instance):
    

    # Remap so we can still use the python types for the simple cases
    global _simple_type_remap
    if datatype_instance in _simple_type_remap:
        return True

    # Now set the protobuf from this interface.
    if isinstance(datatype_instance, (Int64, Double, String, Array)):
        return True

    elif isinstance(datatype_instance, Dictionary):
        kt = datatype_instance.key_type

        if isinstance(kt, (Int64, String)):
            return True

    return False
1161069
def check(self, value, namespace):
        
        return namespace.is_compatible(self.typevar, type(value))
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
294348
def validate_type(value, types, **kwargs):
    
    if not is_value_of_any_type(value, types):
        raise ValidationError(MESSAGES['type']['invalid'].format(
            repr(value), get_type_for_value(value), types,
        ))
901985
def check_type(value, type_def):
        
        if type_def == 'integer':
            try:
                # We accept string with integer ex: '123'
                int(value)
                return True
            except ValueError:
                return isinstance(value, six.integer_types) and not isinstance(value, bool)
        elif type_def == 'number':
            return isinstance(value, (six.integer_types, float)) and not isinstance(value, bool)
        elif type_def == 'string':
            return isinstance(value, (six.text_type, six.string_types, datetime.datetime))
        elif type_def == 'boolean':
            return (isinstance(value, bool) or
                    (isinstance(value, (six.text_type, six.string_types,)) and
                     value.lower() in ['true', 'false'])
                    )
        else:
            return False
645678
def _is_date_data(self, data_type):
        """"""
        dt = DATA_TYPES[data_type]
        if isinstance(self.data, dt['type']):
            self.type = data_type.upper()
            self.len = None
            return True
1072089
def types_validation!(value)
      raise ValidationError if types && types.none? { |type| type === value }
    end
475331
def check_types(value)
      if types&.none? { |type| type === value }
        Lita.logger.fatal(
          I18n.t("lita.config.type_error", attribute: name, types: types.join(", "))
        )

        raise ValidationError
      end
    end
831262
function checkType(value, type) {
  if (typeof type === 'string') {
    switch (type) {
      case 'string':
      case 'object':
      case 'number':
      case 'boolean':
      case 'function':
        return typeof value === type;
      case 'class':
        return typeof value === 'function';
      case 'array':
        return value.constructor === Array;
      default:
        return false;
    }
  }
  else {
    return value instanceof type;
  }
}
685975
protected function checkType(string $type, $value): bool
    {
        switch ($type) {
            case 'array':
                return \is_array($value);

            case 'bool':
            case 'boolean':
                return \is_bool($value);

            case 'callable':
                return \is_callable($value);

            case 'float':
            case 'double':
                return \is_float($value);

            case 'int':
            case 'integer':
                return \is_int($value);

            case 'null':
                return $value === null;

            case 'numeric':
                return \is_numeric($value);

            case 'object':
                return \is_object($value);

            case 'resource':
                return \is_resource($value);

            case 'scalar':
                return \is_scalar($value);

            case 'string':
                return \is_string($value);

            case 'mixed':
                return true;

            default:
                return ($value instanceof $type);
        }
    }
1030398
function(value, type) {
        var result = value;

        if (type === 'string') {
            result = String(value);
        } else if (type === 'number') {
            result = Number(value);
        } else if (type === 'boolean') {
            result = Boolean(value);
        }

        return result;
    }
160882
public static final boolean valueIsNotDefault(FieldType type, Object value)
   {
      boolean result = true;

      if (value == null)
      {
         result = false;
      }
      else
      {
         DataType dataType = type.getDataType();
         switch (dataType)
         {
            case BOOLEAN:
            {
               result = ((Boolean) value).booleanValue();
               break;
            }

            case CURRENCY:
            case NUMERIC:
            {
               result = !NumberHelper.equals(((Number) value).doubleValue(), 0.0, 0.00001);
               break;
            }

            case DURATION:
            {
               result = (((Duration) value).getDuration() != 0);
               break;
            }

            default:
            {
               break;
            }
         }
      }

      return result;
   }
939052
def is_data_value(searchpath, searchtree, dtype = None, empty_is_false = False):
    
    if isinstance(searchpath, (str, unicode, int)):
        searchpath = [searchpath]

    if not isinstance(searchpath, (list, tuple)):
        return False

    for d in searchpath:
        if isinstance(searchtree, dict):
            if not d in searchtree.keys():
                return False

        elif isinstance(searchtree, (list, tuple)):
            if (not isinstance(d, int) or (d >= 0 and d >= len(searchtree)) or (d < 0 and -d > len(searchtree))):
                return False

        else:
            return False

        searchtree = searchtree[d]

    if dtype == None and not (empty_is_false and searchtree == None):
        return True

    if empty_is_false and searchtree in (None, "", {}, []):
        return False

    if isinstance(dtype, tuple):
        dtype = list(dtype)

    elif not isinstance(dtype, list):
        dtype = [dtype]

    if float in dtype and not int in dtype:
        dtype.append(int)

    if str in dtype or unicode in dtype or 'string' in dtype:
        for dtp in (str, unicode, 'string'):
            while dtp in dtype:
                dtype.remove(dtp)
        dtype.extend([str, unicode])

    if list in dtype or tuple in dtype or 'list' in dtype:
        for dtp in (list, tuple, 'list'):
            while dtp in dtype:
                dtype.remove(dtp)
        dtype.extend([list, tuple])

    dtype = tuple(dtype)

    return bool(isinstance(searchtree, dtype))