Validates the type and value of ``value``
347445
def validate_wrap(self, value, *types):
        '''  '''
        for type in types:
            if isinstance(value, type):
                break
        else:
            self._fail_validation_type(value, *types)

        if self.min is not None and value < self.min:
            self._fail_validation(value, 'Value too small')
        if self.max is not None and value > self.max:
            self._fail_validation(value, 'Value too large')
1130731
def value_validate(self, value):
        
        if not isinstance(value, datetime.datetime):
            raise tldap.exceptions.ValidationError("is invalid date time")
837395
def validate(self, value):
        
        errors = []
        value = self._validate_type(value, errors)
        self._validate_value(value, errors)

        if errors:
            raise ValidationErrors(errors)

        return value
657145
def validate(self, value):
        
        value = super(Boolean, self).validate(value)

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

        return value
920752
function isValid (type, value) {
      switch (type) {
        case 'email':
          return validator.isEmail(value);
          break;
        case 'url':
          return validator.isURL(value);
          break;
        case 'domain':
          return validator.isFQDN(value);
          break;
        case 'ip':
          return validator.isIP(value);
          break;
        case 'alpha':
          return validator.isAlpha(value);
          break;
        case 'number':
          return validator.isNumeric(value);
          break;
        case 'alphanumeric':
          return validator.isAlphanumeric(value);
          break;
        case 'base64':
          return validator.isBase64(value);
          break;
        case 'hexadecimal':
          return validator.isHexadecimal(value);
          break;
        case 'hexcolor':
          return validator.isHexColor(value);
          break;
        case 'int':
          return validator.isInt(value);
          break;
        case 'float':
          return validator.isFloat(value);
          break;
        case 'null':
          return validator.isNull(value);
          break;
        case 'uuid':
          return validator.isUUID(value);
          break;
        case 'date':
          return validator.isDate(value);
          break;
        case 'creditcard':
          return validator.isCreditCard(value);
          break;
        case 'isbn':
          return validator.isISBN(value);
          break;
        case 'mobilephone':
          return validator.isMobilePhone(value);
          break;
        case 'json':
          return validator.isJSON(value);
          break;
        case 'ascii':
          return validator.isAscii(value);
          break;
        case 'mongoid':
          return validator.isMongoId(value);
          break;
        default:
          return false;
          break;
      }
    }
778305
def _validate_and_get_value(options, options_name, key, _type):
  
  if isinstance(options, dict):
    has = lambda k: k in options
    get = lambda k: options[k]
  elif isinstance(options, object):
    has = lambda k: hasattr(options, k)
    get = lambda k: getattr(options, k)
  else:
    raise ImproperlyConfigured(
        '`{}` must be a dictionary-like object.'.format(options_name))

  if not has(key):
    raise ImproperlyConfigured(
        '`{}` must be specified in `{}`'.format(key, options_name))

  value = get(key)
  if not isinstance(value, _type):
    raise ImproperlyConfigured(
        '`{}` in `{}` must be a {}'.format(key, options_name, repr(_type)))

  return value
813808
def ensure_valid_default_value(value)
      return unless !value.nil? && types && types.none? { |type| type === value }
      raise TypeError
    end
1126645
def validate_type(self, type_):
        
        if type_ is not None and type_ not in self.types_set:
            raise ValueError('Invalid type for %s:%s' % (self.__class__, type_))
578286
function validateType(type, value) {
	var numberRegex;
	switch (type.toLowerCase()) {
		case 'integer':
		case 'int':
			numberRegex = new RegExp('^[-+]?[0-9]+$');
			if (numberRegex.test(value)) {
				return parseInt(value);
			}
			else {
				throw new InvalidInputError(value + " wasn't of type " + type);
			}
			break;
		case 'number':
		case 'float':
		case 'double':
			numberRegex = new RegExp('^[-+]?[0-9]*([\.,][0-9]+)?$');
			if (numberRegex.test(value)) {
				return parseFloat(value);
			}
			else {
				throw new InvalidInputError(value + " wasn't of type " + type);
			}
			break;
		case 'string':
			//Anything is a string
			return value;
		case 'path':
			// A path that may be relative or absolute. We should parse this into an absolute path
			if(path.isAbsolute(value)) {
				return path.normalize(value);
			}
			return path.resolve(process.cwd(), value);
		default:
			return value;
			break;
	}
}
237641
def validate_to_one(self, value):
        

        if value.rid and self.typeness is int:
            validators.validate_int(value)

        if value.rid and not self.skip_exists:
            if not value.load():
                raise ValidationError(self.messages['exists'])
        return value
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.');
    }
}
998476
def validate_rtype(self, value):
        

        if not value or value != self.rtype:
            msg = self.messages['rtype'].format(self.rtype, value)
            raise ValidationError(msg)
        return value
1222922
def _validate(self, value):
        
        if value is None and not self.nullable:
            self.ctx.errors.invalid('not nullable')
            return False
        return True
713719
def _ValidateValue(value, type_check):
  """"""
  if inspect.isclass(type_check):
    return isinstance(value, type_check)
  if isinstance(type_check, tuple):
    return _ValidateTuple(value, type_check)
  elif callable(type_check):
    return type_check(value)
  else:
    raise TypeError("Invalid type check '%s'" % repr(type_check))
177584
def validate(self, value):
        
        if value in self.empty_values and self.required:
            raise ValidationError(self.error_messages['required'])
322712
def validate_value(self, string_value):
        
        specs = self.specs
        if 'type' in specs:
            value = specs['type'](string_value)
        else:
            value = string_value
        if 'min' in specs and value < specs['min']:
            raise ValueError
        if 'max' in specs and value > specs['max']:
            raise ValueError
        if 'valid' in specs and value not in specs['valid']:
            raise ValueError
        return value
124231
def _validate(self, value):
        """"""
        if self.values and value not in self.values:
            raise ValueError(
                '{} is not a valid value for {}'.format(value, self.name))