Validate the contents of the object.

        This calls ``setattr`` for each of the class's grammar properties. It
        will catch ``ValueError``s raised by the grammar property's setters
        and re-raise them as :class:`ValidationError`.
509166
def validate(self):
        
        for key, val in self.grammar.items():
            try:
                setattr(self, key, val)
            except ValueError as e:
                raise ValidationError('invalid contents: ' + e.args[0])
717686
def check(self):
        
        try:
            value = self.raw_value
        except (AttributeError, KeyError) as err:
            self._reraise_if_required(err)
        else:
            if self.checker:
                self.checker(self.full_name, value)
            try:
                self.validate(value)
                self.run_validators(value)
            except ValidationError as error:
                raise ValueError("Setting {} has an invalid value: {}".format(self.full_name, error))
565220
def _validate(self):  # type: () -> None
        """"""
        # class can specify it's empty obj -- list would have empty of []
        self._errors = []

        self._validate_type()

        if self.is_valid():
            self._validate_value()
177584
def validate(self, value):
        
        if value in self.empty_values and self.required:
            raise ValidationError(self.error_messages['required'])
191280
def validate(self):
        
        properties = (
            getattr(self.__class__, prop)
            for prop in self._property_list
            if hasattr(self.__class__, prop)
        )

        all_valid = True
        for prop in properties:
            if hasattr(prop, "validate"):
                # oh for fucks sake, brython has broken parser and return in
                # prop.validate() will also return from this function if used
                # with `and` operator
                result = prop.validate()
                all_valid = all_valid and result

        return all_valid
1248452
def validate_kwargs(self, kwargs):
        
        if not self.response_type:
            msg = "response_type must be set on the Response subclass."
            raise ValidationException(msg)

        if (self.key_name and self.key_name in kwargs) or "type" in kwargs:
            name = self.__class__.__name__
            msg = "%s is an invalid argument for %s" % (self.key_name, name)
            raise ValidationException(msg)
224557
def _validate_empty_attributes(self, attributes):
        """"""
        attrs_to_check = set(self._required) & set(attributes)
        for attr in attrs_to_check:
            value = getattr(self, attr)  # We should always have a value here
            if value is None or value == "":
                raise ValueError(
                    "Attribute %s cannot be None or an empty string since it is required." % attr
                )
853800
def validate(self):
        
        if getattr(self, '_getting_validated', False):
            return True
        self._getting_validated = True
        self._validation_error_tuples = []
        self._non_validation_error = None
        try:
            for val in itervalues(self._class_validators):
                try:
                    if isinstance(val.func, string_types):
                        valid = getattr(self, val.func)()
                    else:
                        valid = val.func(self)
                    if valid is False:
                        raise utils.ValidationError(
                            'Validation failed', None, None, self
                        )
                except utils.ValidationError as val_err:
                    self._validation_error_tuples += val_err.error_tuples
                except GENERIC_ERRORS as err:
                    if not self._non_validation_error:
                        self._non_validation_error = err
            if self._validation_error_tuples:
                self._error_hook(self._validation_error_tuples)
                msgs = ['Validation failed:']
                msgs += [val.message for val in self._validation_error_tuples]
                raise utils.ValidationError(
                    message='\n- '.join(msgs),
                    _error_tuples=self._validation_error_tuples,
                )
            if self._non_validation_error:
                raise self._non_validation_error                               #pylint: disable=raising-bad-type
            return True
        finally:
            self._getting_validated = False
            self._validation_error_tuples = None
            self._non_validation_error = None
1016543
function(attr, value) {
          var self = this,
              result = {},
              error;

          if(_.isObject(attr)){
            _.each(attr, function(value, key) {
              error = self.preValidate(key, value);
              if(error){
                result[key] = error;
              }
            });

            return _.isEmpty(result) ? undefined : result;
          }
          else {
            return validateAttr(this, attr, value, _.extend({}, this.attributes));
          }
        }
1211331
def _validate(self):
        
        errors = {}

        for name, validator in self._validators.items():
            value = getattr(self, name)

            try:
                validator(self, value)
            except ValidationError as e:
                errors[name] = str(e)

        self._validate_errors = errors
412570
def validate(self):
        
        for field_name, field_obj in self._fields.items():
            value = field_obj.__get__(self, self.__class__)

            if value is None and field_obj.null is False:
                raise ValidationError('Non-nullable field {0} is set to None'.format(field_name))
            elif value is None and field_obj.null is True:
                # no further validations are possible on NoneType field
                continue

            if isinstance(field_obj, NestedDocumentField):
                value.validate()
            else:
                field_obj.validate(value)
155169
def validate(self, obj, pointer=None):
        

        pointer = pointer or '#'

        validator = deepcopy(self)
        validator.errors = []
        validator.fail_fast = False

        obj = deepcopy(obj)
        obj = validator.validate_enum(obj, pointer)
        obj = validator.validate_type(obj, pointer)
        obj = validator.validate_disallow(obj, pointer)
        obj = validator.validate_extends(obj, pointer)

        if validator.is_array(obj):
            obj = validator.validate_max_items(obj, pointer)
            obj = validator.validate_min_items(obj, pointer)
            obj = validator.validate_items(obj, pointer)
            obj = validator.validate_unique_items(obj, pointer)

        if validator.is_number(obj):
            obj = validator.validate_maximum(obj, pointer)
            obj = validator.validate_minimum(obj, pointer)
            obj = validator.validate_divisible_by(obj, pointer)

        if validator.is_object(obj):
            obj = validator.validate_dependencies(obj, pointer)
            obj = validator.validate_properties(obj, pointer)

        if validator.is_string(obj):
            obj = validator.validate_max_length(obj, pointer)
            obj = validator.validate_min_length(obj, pointer)
            obj = validator.validate_pattern(obj, pointer)
            obj = validator.validate_format(obj, pointer)

        if validator.errors:
            raise ValidationError('multiple errors',
                                  obj,
                                  errors=validator.errors)

        return obj
973522
def _validate_data(data, schema, validator_cls):
    
    validator = validator_cls(schema)
    _errors = defaultdict(list)
    for err in validator.iter_errors(data):
        path = err.schema_path

        # Code courtesy: Ruslan Karalkin
        # Looking in error schema path for
        # property that failed validation
        # Schema example:
        # {
        #    "type": "object",
        #    "properties": {
        #        "foo": {"type": "number"},
        #        "bar": {"type": "string"}
        #     }
        #    "required": ["foo", "bar"]
        # }
        #
        # Related err.schema_path examples:
        # ['required'],
        # ['properties', 'foo', 'type']

        if "properties" in path:
            path.remove("properties")
        key = path.popleft()

        # If validation failed by missing property,
        # then parse err.message to find property name
        # as it always first word enclosed in quotes
        if key == "required":
            key = err.message.split("'")[1]

        _errors[key].append(str(err))

    if _errors:
        _raise_exception(
            web.HTTPBadRequest,
            "Request is invalid; There are validation errors.",
            _errors)
936942
function() {
    // Check for unknown attributes
    var key, unknownAttrs = []
    for (key in obj) {
      if (!self.validators.hasOwnProperty(key))
        unknownAttrs.push(key)
    }
    if (unknownAttrs.length)
      self._merge(validationErrors, 'unknown attributes [' + unknownAttrs.join(', ') + ']', prefix)
      //validationErrors[prefix || '.'] = 'unknown attributes [' + unknownAttrs.join(', ') + ']'

    // Run the `after` hook only if there is no validation error.
    if (isValid && self.after) {
      try {
        self.after.call(obj)
      } catch (err) {
        if(!_handleError(err)) return done(err)
      }
    }
    done(null, validationErrors)
  }
551506
def validate(mcs, bases, attributes):
        """"""
        if bases[0] is object:
            return None
        mcs.check_model_cls(attributes)
        mcs.check_include_exclude(attributes)
        mcs.check_properties(attributes)
687171
def validate_attributes!(attributes)
      return attributes if attributes.blank?
      invalid_properties = attributes.keys.map(&:to_s) - self.attributes.keys
      invalid_properties.reject! { |name| self.respond_to?("#{name}=") }
      fail UndefinedPropertyError, "Undefined properties: #{invalid_properties.join(',')}" if !invalid_properties.empty?
    end
612644
def validate(self, instance, value):
        
        if not self.coerce and not isinstance(value, self._class_container):
            self.error(instance, value)
        if self.coerce and not isinstance(value, CONTAINERS):
            value = [value]
        if not isinstance(value, self._class_container):
            out_class = self._class_container
        else:
            out_class = value.__class__
        out = []
        for val in value:
            try:
                out += [self.prop.validate(instance, val)]
            except ValueError:
                self.error(instance, val, extra='This item is invalid.')
        return out_class(out)