Validate against a specific type.
14306
def check_type(type)
      if type.respond_to?(:validate!)
        type.validate!(self)
      elsif klass = self.class.factory(type.to_s)
        klass.new.validate!(self)
      else
        raise "invalid type supplied for validation check"
      end
    end
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))
1294227
def register_type(cls, name):
    """"""
    x = TypeDefinition(name, (cls,), ())
    Validator.types_mapping[name] = x
1370108
def validate( self ):
        """"""
        klass = self.__class__

        for name in klass._fields:
            self.validate_field( name )
        return
860900
def _validate_place_types(self, types):
        """"""
        for pt in types:
            if pt not in self.place_types:
                raise InvalidPlaceTypeError(pt)
        return {'types': ",".join(types)}
477784
def validate(self, input_parameters, context):
        """"""
        errors = {}

        for key, type_handler in self.input_transformations.items():
            if self.raise_on_invalid:
                if key in input_parameters:
                    input_parameters[key] = self.initialize_handler(
                        type_handler,
                        input_parameters[key],
                        context=context
                    )
            else:
                try:
                    if key in input_parameters:
                        input_parameters[key] = self.initialize_handler(
                            type_handler,
                            input_parameters[key],
                            context=context
                        )
                except InvalidTypeData as error:
                    errors[key] = error.reasons or str(error.message)
                except Exception as error:
                    if hasattr(error, 'args') and error.args:
                        errors[key] = error.args[0]
                    else:
                        errors[key] = str(error)
        for require in self.required:
            if not require in input_parameters:
                errors[require] = "Required parameter '{}' not supplied".format(require)
        if not errors and getattr(self, 'validate_function', False):
            errors = self.validate_function(input_parameters)
        return errors
1010143
def checktype(self, val, kind, **kargs):
        """"""
        if not isinstance(val, kind):
            raise TypeError('Expected {}; got {}'.format(
                            self.str_kind(kind), self.str_valtype(val)))
240426
def validate(cls, data, name, **kwargs):
        """"""
        required = kwargs.get('required', False)
        if required and data is None:
            raise ValidationError("required", name, True)
        elif data is None:
            return
        elif kwargs.get('readonly'):
            return

        try:
            for key, value in kwargs.items():
                validator = cls.validation.get(key, lambda x, y: False)
                if validator(data, value):
                    raise ValidationError(key, name, value)
        except TypeError:
            raise ValidationError("unknown", name, "unknown")
        else:
            return data
886167
def _validate_python_type(self, python_type):
        """"""

        if python_type == 'bool':
            if self.variable:
                raise ArgumentError("You can only specify a bool python type on a scalar (non-array) type_name", type_name=self.type_name)

            return

        if python_type == 'string':
            if not (self.variable and self.unit_size == 1):
                raise ArgumentError("You can only pass a string python type on an array of 1-byte objects", type_name=self.type_name)

            return

        if python_type is not None:
            raise ArgumentError("You can only declare a bool or string python type.  Otherwise it must be passed as None", python_type=python_type)
1077210
def _validate_type(self, item, name):
        """"""
        if item is None:
            # don't validate None items, since they'll be caught by the portion
            # of the validator responsible for handling `required`ness
            return

        if not isinstance(item, self.allowed_types):
            item_class_name = item.__class__.__name__
            raise ArgumentError(name,
                "Expected one of %s, but got `%s`" % (
                    self.allowed_types, item_class_name))
367163
def validate(self, data, schema, **kwargs):
        """"""
        if not isinstance(schema, dict):
            schema = {'$ref': schema}
        return validate(
            data,
            schema,
            resolver=self.ref_resolver_cls.from_schema(schema),
            types=self.app.config.get('RECORDS_VALIDATION_TYPES', {}),
            **kwargs
        )
1101139
def _validated(self, values):
        """"""
        if self.length != len(values):
            raise NotValid(
                "%r does not have exactly %d values. (Got %d.)" % (
                    values, self.length, len(values)))
        return type(self.schemas)(
            self.schemas[i].validate(v) for i, v in enumerate(values))
216175
def validate_member_type(self, value):
        """"""
        if self.member_type:
            for item in value:
                self.member_type.validate(item)
125420
def _check_type(self, check_type, properties):
        """"""
        if 'PrimitiveType' in properties:
            return properties['PrimitiveType'] == check_type
        if properties['Type'] == 'List':
            if 'ItemType' in properties:
                return properties['ItemType'] == check_type
            else:
                return properties['PrimitiveItemType'] == check_type
        return False
921736
def _validated(self, data):
        """"""
        try:
            return self.convert(data)
        except (TypeError, ValueError) as ex:
            raise NotValid(*ex.args)
816923
def validate(self, obj):
        """"""
        try:
            if self.resolver is not None:
                jsonschema.validate(obj, self.schema, resolver=self.resolver)
            else:
                jsonschema.validate(obj, self.schema)
        except jsonschema.ValidationError as exc:
            raise exceptions.ValidationError(str(exc))
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')