See the descritpion of :func:`validate` for more details of parameters and
    return value.

    Validate target object 'data' with given schema object.
334712
def _validate(data, schema, ac_schema_safe=True, **options):
    
    try:
        jsonschema.validate(data, schema, **options)

    except (jsonschema.ValidationError, jsonschema.SchemaError,
            Exception) as exc:
        if ac_schema_safe:
            return (False, str(exc))  # Validation was failed.
        raise

    return (True, '')
1365328
function(node, name, data) {
  typeCheckString(key, 'key');
  typeCheckObject(data, 'data');
  typeCheckObject(node, 'node');
  runValidator(node, 'node');

  if (typeof node !== 'object') {
    throw new error.InvalidParameterError(
      'Parameter ast must be a well-defined JSON object.'
    );
  }
  if (validator(node)) {
    throw new error.MalformedAstError(
      'Parameter ast needs to be a JSON structure according to the schema.'
    );
  }
  if (typeof data !== 'object') {
    throw new error.InvalidParameterError(
      'Parameter data must be a well-defined JSON object.'
    );
  }
  if (typeof name !== 'string') {
    throw new error.InvalidParameterError('Parameter name must be a string.');
  }
  const newNode = Object.assign({}, node);
  if (newNode.properties) {
    newNode.properties[name] = data;
  }
  return newNode;
}
777094
function validateEndpointData(
  data,
  { prettyErrorMessage = 'invalid response data', includeKeys = false } = {}
) {
  return validate(
    {
      ErrorClass: InvalidResponse,
      prettyErrorMessage,
      includeKeys,
      traceErrorMessage: 'Response did not match schema',
      traceSuccessMessage: 'Response after validation',
      allowAndStripUnknownKeys: false,
    },
    data,
    endpointSchema
  )
}
611452
def traverser(self, data, schema, tree):
        
        if hasattr(schema, '__validator_leaf__'):
            return schema(data, tree)

        if hasattr(schema, 'must_validate'):  # cherry picking?
            if not len(schema.must_validate):
                reason = "must_validate attribute must not be empty"
                raise SchemaError(data, tree, reason=reason)
            data = sift(data, schema.must_validate)

        schema = self.sanitize_optionals(data, schema, tree)
        self.is_alpha_ordered(data, schema, tree)

        validated_indexes = []
        skip_missing_indexes = getattr(schema, 'must_validate', False)

        if len(data) < len(schema):
            # we have missing required items in data, but we don't know
            # which ones so find what may fail:
            data_keys = [v[0] for v in data.values()]
            schema_keys = [v[0] for v in schema.values()]

            def enforce_once(data_keys, schema_key):
                # XXX Go through all the data keys and try and see if they pass
                # validation against the schema. At this point it is impossible
                # to know which data key corresponds to what schema key
                # (because schema keys can be a function/callable) so it is
                # a *very* naive way to try and detect which one might be
                # missing
                for data_key in data_keys:
                    failed = None
                    try:
                        enforce(data_key, schema_key, tree, pair='key')
                        return
                    except Invalid:
                        failed = data_key, schema_key

                    if failed:
                        return failed

            # if there are no callables in the schema keys, just
            # find the missing data key directly
            if all([not is_callable(s) for s in schema_keys]):
                for schema_key in schema_keys:
                    if schema_key not in data_keys:
                        msg = "required key in data is missing: %s" % str(schema_key)
                        raise Invalid(None, tree, reason=msg, pair='key')

            for schema_key in schema_keys:
                failure = enforce_once(data_keys, schema_key)
                if failure:
                    _, failed_schema_key = failure
                    msg = "required key in data is missing: %s" % str(failed_schema_key)
                    raise Invalid(None, tree, reason=msg, pair='key')

        for index in range(len(data)):
            self.length_equality(data, schema, index, tree)
            key, value = data[index]
            skey, svalue = schema[index]
            tree.append(key)

            # Validate the key before anything, to prevent recursing
            self.key_leaf(data[index], schema[index], tree)

            # If a dict is a value we need to recurse.
            # XXX Should we check isinstance(value, ndict) ?
            if isinstance(value, dict) and len(value):
                self.traverser(value, svalue, tree)
            else:
                self.value_leaf(data[index], schema[index], tree)
            if tree:
                tree.pop()

            validated_indexes.append(index)

        # XXX There is a chance we might have missing items from
        # the incoming data that are labeled as required from the schema
        # we should make sure *here* that we account for that and raise
        # the appropriate exception. Since the loop finished and everything
        # seems to have passed, this lack of check will give false positives.
        missing_indexes = set(schema.keys()).difference(validated_indexes)
        if missing_indexes:
            if skip_missing_indexes:
                return
            for i in missing_indexes:
                if not hasattr(schema[i], 'is_optional'):
                    required_key = schema[i][0]
                    tree.append('item[%s]' % i)
                    msg = "required item in schema is missing: %s" % str(required_key)
                    raise Invalid(required_key, tree, reason=msg, pair='key')
1054129
def returns(schema):
    
    validate = parse(schema).validate

    @decorator
    def validating(func, *args, **kwargs):
        ret = func(*args, **kwargs)
        validate(ret, adapt=False)
        return ret
    return validating
653169
def validate(schema, data, owner=None):
    
    schema._validate(data=data, owner=owner)
148705
def validate(data)
      JSON::Validator.validate!(self, data)
    rescue JSON::Schema::ValidationError => e
      raise DataPackage::ValidationError.new(e.message)
    end
844767
def validate(self, schema):
        
        try:
            validate(instance=self.to_dict(), schema=schema, cls=Draft4Validator)
        except ValidationError as e:
            raise ValidationError(_validate_err_template.format(VDOM_SCHEMA, e))
1355281
def validate(json)
      schema_key = Resolver.get_schema_key json
      data = Resolver.get_data json
      schema = lookup_schema schema_key
      JSON::Validator.validate!(schema, data)
    end
451450
def validate(self, **kwargs):
        

        default_data_schema = json.load(open(self.default_schema_file, 'r'))

        # even though we are using the yaml package to load,
        # it supports JSON and YAML
        data = kwargs.pop("data", None)
        file_path = kwargs.pop("file_path", None)

        if file_path is None:
            raise LookupError("file_path argument must be supplied")

        if data is None:

            try:
                data = yaml.load(open(file_path, 'r'), Loader=Loader)
            except Exception as e:
                self.add_validation_message(ValidationMessage(file=file_path, message=
                'There was a problem parsing the file.\n' + e.__str__()))
                return False

        try:

            if 'type' in data:
                custom_schema = self.load_custom_schema(data['type'])
                json_validate(data, custom_schema)
            else:
                json_validate(data, default_data_schema)

        except ValidationError as ve:

            self.add_validation_message(
                ValidationMessage(file=file_path,
                                    message=ve.message + ' in ' + str(ve.instance)))

        if self.has_errors(file_path):
            return False
        else:
            return True
340859
def validate(self, ymldata=None, messages=None):
        """"""
        schema_val = self.schema_val(messages)
        if len(messages) == 0:
            content_val = self.content_val(ymldata, messages)

        return schema_val and content_val
1270837
def validate_parameters(cls, parameters, schema=None):
        
        if schema is None:
            schema = cls.get_parameters_schema()
        jsonschema.validate(parameters, schema)
57025
function validator (data, schema) {
  const result = Object.assign({}, data)
  Object.keys(schema).map(key => {
    let value = schema[key]
    const type = typeof value
    if (type !== 'object') {
      value = {
        transform: value
      }
    }
    validate(value, result, key)
  })
  return result
}
79273
def validate(request_schema=None, response_schema=None):
    
    def wrapper(func):
        # Validating the schemas itself.
        # Die with exception if they aren't valid
        if request_schema is not None:
            _request_schema_validator = validator_for(request_schema)
            _request_schema_validator.check_schema(request_schema)

        if response_schema is not None:
            _response_schema_validator = validator_for(response_schema)
            _response_schema_validator.check_schema(response_schema)

        @asyncio.coroutine
        @functools.wraps(func)
        def wrapped(*args):
            if asyncio.iscoroutinefunction(func):
                coro = func
            else:
                coro = asyncio.coroutine(func)

            # Supports class based views see web.View
            if isinstance(args[0], AbstractView):
                class_based = True
                request = args[0].request
            else:
                class_based = False
                request = args[-1]

            # Strictly expect json object here
            try:
                req_body = yield from request.json()
            except (json.decoder.JSONDecodeError, TypeError):
                _raise_exception(
                    web.HTTPBadRequest,
                    "Request is malformed; could not decode JSON object.")

            # Validate request data against request schema (if given)
            if request_schema is not None:
                _validate_data(req_body, request_schema,
                               _request_schema_validator)

            coro_args = req_body, request
            if class_based:
                coro_args = (args[0], ) + coro_args

            context = yield from coro(*coro_args)

            # No validation of response for websockets stream
            if isinstance(context, web.StreamResponse):
                return context

            # Validate response data against response schema (if given)
            if response_schema is not None:
                _validate_data(context, response_schema,
                               _response_schema_validator)

            try:
                return web.json_response(context)
            except (TypeError, ):
                _raise_exception(
                    web.HTTPInternalServerError,
                    "Response is malformed; could not encode JSON object.")

        # Store schemas in wrapped handlers, so it later can be reused
        setattr(wrapped, "_request_schema", request_schema)
        setattr(wrapped, "_response_schema", response_schema)
        return wrapped
    return wrapper
737705
function validateObject(node, schema, key) {
    if (typeof node == "object") {
      try {
        validateModel(node, schema[SCHEMADATA]);
      } catch (e) {
        throw new ValidationException(e.message + " at " + key + ".");
      }
    } else {
      throw new ValidationException("Expected object for " + key);
    }
  }
1263892
def validate(self, *args):
        
        super(self.__class__, self).validate(*args)
        if not self.name:
            raise ValidationError('name is required for Data')
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
        )