Validates the given data and raises an error if any non-allowed keys are
    provided or any required keys are missing.

    :param data: Data to send to API
    :type data: dict
772743
def _validate_data(data):
    
    data_keys = set(data.keys())
    extra_keys = data_keys - set(ALLOWED_KEYS)
    missing_keys = set(REQUIRED_KEYS) - data_keys

    if extra_keys:
        raise ValueError(
            'Invalid data keys {!r}'.format(', '.join(extra_keys))
        )

    if missing_keys:
        raise ValueError(
            'Missing keys {!r}'.format(', '.join(missing_keys))
        )
679168
def validate(self, data):
        
        for v in self.validators:
            v(self, data)
        return data
257002
def validate(data):
    
    text = data.get('text')
    if not isinstance(text, _string_types) or len(text) == 0:
        raise ValueError('text field is required and should not be empty')

    if 'markdown' in data and not type(data['markdown']) is bool:
        raise ValueError('markdown field should be bool')

    if 'attachments' in data:
        if not isinstance(data['attachments'], (list, tuple)):
            raise ValueError('attachments field should be list or tuple')

        for attachment in data['attachments']:
            if 'text' not in attachment and 'title' not in attachment:
                raise ValueError('text or title is required in attachment')

    return True
440952
def validate(self, data):
        
        for s in [self._schema(s, error=self._error, ignore_extra_keys=self._ignore_extra_keys) for s in self._args]:
            data = s.validate(data)
        return data
672785
def _validate_features(self, data):
        
        if self.feature_names is None:
            self.feature_names = data.feature_names
            self.feature_types = data.feature_types
        else:
            # Booster can't accept data with different feature names
            if self.feature_names != data.feature_names:
                dat_missing = set(self.feature_names) - set(data.feature_names)
                my_missing = set(data.feature_names) - set(self.feature_names)

                msg = 'feature_names mismatch: {0} {1}'

                if dat_missing:
                    msg += ('\nexpected ' + ', '.join(str(s) for s in dat_missing) +
                            ' in input data')

                if my_missing:
                    msg += ('\ntraining data did not have the following fields: ' +
                            ', '.join(str(s) for s in my_missing))

                raise ValueError(msg.format(self.feature_names,
                                            data.feature_names))
462288
def validate(self, data):
        
        e = self._error

        try:
            if self._pattern.search(data):
                return data
            else:
                raise SchemaError("%r does not match %r" % (self, data), e)
        except TypeError:
            raise SchemaError("%r is not string nor buffer" % data, e)
1016439
def _check_json_data(self, json_data):
        
        if not isinstance(json_data, dict):
            raise BadRequestError('Request body should be a JSON hash')
        if 'data' not in json_data.keys():
            raise BadRequestError('Request should contain data key')
412968
def _validate(self, data: Any, schema: AnyMapping) -> Any:
        
        try:
            return self.validate_func(schema, self._pure_data(data))
        except self.validation_error_class as err:
            logger.error(
                'Schema validation error',
                exc_info=True,
                extra={'schema': schema, 'schema_module': self.module})
            if self.error_class is None:
                raise
            raise self.make_error('Validation Error', error=err) from err
4155
def run_validation(self, data=empty):
        
        (is_empty_value, data) = self.validate_empty_values(data)
        if is_empty_value:
            return data

        value = self.to_internal_value(data)
        try:
            self.run_validators(value)
            value = self.validate(value)
            assert value is not None, '.validate() should return the validated data'
        except (ValidationError, DjangoValidationError) as exc:
            raise ValidationError(detail=get_validation_error_detail(exc))

        return value
1141372
def validate_config(data: dict) -> dict:
        """"""
        errors = ConfigSchema().validate(data)
        if errors:
            for field, messages in errors.items():
                if isinstance(messages, dict):
                    for level, sample_errors in messages.items():
                        sample_id = data['samples'][level]['sample_id']
                        for sub_field, sub_messages in sample_errors.items():
                            LOG.error(f"{sample_id} -> {sub_field}: {', '.join(sub_messages)}")
                else:
                    LOG.error(f"{field}: {', '.join(messages)}")
            raise ConfigError('invalid config input', errors=errors)
697241
def validate_data_provider(value)
      if value.is_a?(String)
        unless value =~ /^[a-zA-Z][a-zA-Z0-9_]*$/
          if value =~ /^[a-zA-Z]/
            raise ArgumentError, _("field 'data_provider' contains non-alphanumeric characters")
          else
            raise ArgumentError, _("field 'data_provider' must begin with a letter")
          end
        end
      else
        raise ArgumentError, _("field 'data_provider' must be a string")
      end
    end
744645
def _validate(self):
        
        if not is_valid_subject(self.subject):
            raise MessageError("Invalid subject: '%s'" % self.subject)
        if not is_valid_type(self.type):
            raise MessageError("Invalid type: '%s'" % self.type)
        if not is_valid_sender(self.sender):
            raise MessageError("Invalid sender: '%s'" % self.sender)
        if not self.binary and not is_valid_data(self.data):
            raise MessageError("Invalid data: data is not JSON serializable: %s"
                               % str(self.data))
1340805
def _get_validate(data):
    
    if data.get("vrn_file") and tz.get_in(["config", "algorithm", "validate"], data):
        return utils.deepish_copy(data)
    elif "group_orig" in data:
        for sub in multi.get_orig_items(data):
            if "validate" in sub["config"]["algorithm"]:
                sub_val = utils.deepish_copy(sub)
                sub_val["vrn_file"] = data["vrn_file"]
                return sub_val
    return None
232117
def _validate_source_data(self):
        

        try:
            jsonschema.validate(self._buffer, self._schema)
        except jsonschema.ValidationError as e:
            raise ValidationError(e)
1091986
def validate(self, data_access=None):
    
    self.clear_errors()
    self.before_validation()
    self.validator.validate(self, data_access)
    return not self.has_errors
817325
def _validate_data(self):
        
        msg = "Error! Expected {} timestamps, found {}.".format(
            len(self._data_points), len(self._timestamps))
        if len(self._data_points) != len(self._timestamps):
            raise MonsoonError(msg)
483628
def _check_valid_data(self, data):
        
        if data.dtype.type is not np.float32 and \
           data.dtype.type is not np.float64:
            raise ValueError(
                'Illegal data type. RGB-D images only support float arrays')

        if len(data.shape) != 3 and data.shape[2] != 4:
            raise ValueError(
                'Illegal data type. RGB-D images only support four channel')

        color_data = data[:, :, :3]
        if np.any((color_data < 0) | (color_data > BINARY_IM_MAX_VAL)):
            raise ValueError(
                'Color channels must be in the range (0, BINARY_IM_MAX_VAL)')