Checks that `val` adheres to type `ty`
501298
def check(ty, val):
    ""
    
    if isinstance(ty, basestring):
        ty = Parser().parse(ty)

    return ty.enforce(val)
708232
function (val) {
  return (!behavior.enableUndefined || typeof val !== 'undefined')
    && (!behavior.enableNull || val !== null)
    && (!behavior.enableFalse || val !== false)
    && (!behavior.enableNaN || !Number.isNaN(val));
}
331151
def has_value_of_type(self, var_type):
        
        if self.has_value() and self.has_type(var_type):
            return True
        return False
1162502
function toDefault(val, def) {
    if (is_1.isValue(val) && !(is_1.isEmpty(val) && !is_1.isEmpty(def)))
        return val;
    return is_1.isValue(def) ? def : null;
}
562637
function(type, val){
    var res = {type: type, line: this.lineno, col: this.colno};

    if (val !== undefined) res.val = val;

    return res;
  }
1056705
def check(self, inst, value):
        
        if not (self.or_none and value is None):
            if self.seq:
                self.checktype_seq(value, self.kind,
                                   unique=self.unique, inst=inst)
            else:
                self.checktype(value, self.kind, inst=inst)
674333
function validateTypeAmong(startPos, endPos, x, types) {
  /* Succeed if the type of x is in the list 'types' */
  for (let type of types) {
    if (joinTypes(x.type(), type) !== null) {
      return;
    }
  }
  /* Report error */
  fail(startPos, endPos,
    'expected-value-of-some-type-but-got', [
      types,
      x.type()
    ]
  );
}
698426
def _pretty_const_type_val(typecode, val):
    

    if typecode == CONST_Utf8:
        typestr = "Utf8"  # formerly Asciz, which was considered Java bug
        if not isinstance(val, str):  # Py2, val is 'unicode'
            val = repr(val)[2:-1]  # trim off the surrounding u"" (HACK)
        else:
            val = repr(val)[1:-1]  # trim off the surrounding "" (HACK)
    elif typecode == CONST_Integer:
        typestr = "int"
    elif typecode == CONST_Float:
        typestr = "float"
        val = "%ff" % val
    elif typecode == CONST_Long:
        typestr = "long"
        val = "%il" % val
    elif typecode == CONST_Double:
        typestr = "double"
        val = "%fd" % val
    elif typecode == CONST_Class:
        typestr = "class"
        val = "#%i" % val
    elif typecode == CONST_String:
        typestr = "String"
        val = "#%i" % val
    elif typecode == CONST_Fieldref:
        typestr = "Field"
        val = "#%i.#%i" % val
    elif typecode == CONST_Methodref:
        typestr = "Method"
        val = "#%i.#%i" % val
    elif typecode == CONST_InterfaceMethodref:
        typestr = "InterfaceMethod"
        val = "#%i.#%i" % val
    elif typecode == CONST_NameAndType:
        typestr = "NameAndType"
        val = "#%i:#%i" % val
    elif typecode == CONST_ModuleId:
        typestr = "ModuleId"
        val = "#%i@#%i" % val
    elif typecode == CONST_MethodHandle:
        typestr = "MethodHandle"
        val = repr(val)
    elif typecode == CONST_MethodType:
        typestr = "MethodType"
        val = repr(val)
    elif typecode == CONST_InvokeDynamic:
        typestr = "InvokeDynamic"
        val = repr(val)
    else:
        raise Unimplemented("unknown constant type %r" % typecode)

    return typestr, val
756879
function check(value, ...validators) {
    let valid = false;
    _.each(validators, (validator) => {
        return !(valid = validator(value));
    });

    if (!valid) {
        throw new TypeError('Argument is not any of the accepted types.');
    }
}
1083272
def _check_valid(key, val, valid):
    """"""
    if val not in valid:
        raise ValueError('%s must be one of %s, not "%s"'
                         % (key, valid, val))
270231
def _guess_type(val):
        """"""
        if isinstance(val, bool):
            return "choice"
        elif isinstance(val, int):
            return "number"
        elif isinstance(val, float):
            return "number"
        elif isinstance(val, str):
            return "text"
        elif hasattr(val, 'read'):
            return "file"
        else:
            return "text"
446725
def _is_type_compatible(a, b):
    """"""
    is_ts_compat = lambda x: isinstance(x, (Timestamp, DateOffset))
    is_td_compat = lambda x: isinstance(x, (Timedelta, DateOffset))
    return ((is_number(a) and is_number(b)) or
            (is_ts_compat(a) and is_ts_compat(b)) or
            (is_td_compat(a) and is_td_compat(b)) or
            com._any_none(a, b))
1368726
def validate_all_types(kwargs):
        
        for key in kwargs:
            assert isinstance(kwargs[key], type), """\n
    Typedtuple needs its arguments to be types. Argument "{k:}" was {type_name:}({val_repr}).
    You might want to try:
        {k:} = {type_name:}\n\n""".format(k=key, type_name=type(kwargs[key]).__name__, val_repr=kwargs[key].__repr__())
560467
function isDotNotation(val) {
    if (!chek_1.isString(val))
        return false;
    return /\..*\./.test(val) && !val.match(/\s/);
}
886835
private boolean checkForMapValue(TabularType pType) {
        CompositeType rowType = pType.getRowType();
        // Two entries in the row: "key" and "value"
        return rowType.containsKey(TD_KEY_VALUE) && rowType.containsKey(TD_KEY_KEY) && rowType.keySet().size() == 2;
    }
916100
def cast_value(val, totype):
    
    t = type(val)
    if issubclass(t, totype):
        return val  # no cast needed
    if issubclass(totype, bytes):
        return bytes(val)
    if issubclass(totype, str):
        return str(val)
    if issubclass(totype, bool):
        if issubclass(t, str):
            _v = val.lower()
            if _v in ("true", "yes", "y"):
                return True
            if _v in ("false", "no", "n"):
                return False
            raise TypeError("Not able to cast value: " + str(val) +
                            " with " + str(t) +
                            " to " + str(totype))

    if (issubclass(totype, (int, float)) and
        issubclass(t, (bytes, str, int, float))):
        if val:
            return totype(float(val))
        else:
            return totype(0)

    raise TypeError("Not able to cast value:" + str(val) +
                    " with " + str(t) +
                    " to " + str(totype))
947560
def enforce_type(self, attr, val):
        """"""
        if not attr in self.types:
            return utfstr(val)
        elif self.types[attr] == 'int':
            return int(float(val))
        elif self.types[attr] == 'float':
            return float(val)
        else:
            return utfstr(val)