@function requireValidSchema

validate schema argument

@param {object} schema

@returns {object}

@throws {Error}
5049
function requireValidSchema (schema) {
    // throw error on invalid schema object
    assert.equal(typeof schema, 'object', 'schema must be object')
    assert.equal(typeof schema.columns, 'object', 'schema columns must be object')
    assert.ok(Array.isArray(schema.indexes), 'schema indexes must be array')
    // require validated schema
    return schema
}
1254281
function Validation(schema, custom) {
		Inspection.prototype.constructor.call(this, schema, _merge(Validation.custom, custom));
		var _error = [];

		this._basicFields = Object.keys(_validationAttribut);
		this._customFields = Object.keys(this._custom);
		this.origin = null;

		this.report = function (message, code, reason) {
			var newErr = {
				code: code || this.userCode || null,
				reason: reason || 'unknown',
				message: this.userError || message || 'is invalid',
				property: this.userAlias ? (this.userAlias + ' (' + this._dumpStack() + ')') : this._dumpStack()
			};
			_error.push(newErr);
			return this;
		};

		this.result = function () {
			return {
				error: _error,
				valid: _error.length === 0,
				format: function () {
					if (this.valid === true) {
						return 'Candidate is valid';
					}
					return this.error.map(function (i) {
						return 'Property ' + i.property + ': ' + i.message;
					}).join('\n');
				}
			};
		};
	}
29309
public Status validate(final Object value, final Property schema) {
        return doValidate(value, schema, null);
    }
1132518
private void validateSchema(Schema schema) throws DDFException {
    Set<String> columnSet = new HashSet<String>();
    if(schema != null && schema.getColumns() != null) {
      for (Column column : schema.getColumns()) {
        if (columnSet.contains(column.getName())) {
          throw new DDFException(String.format("Duplicated column name %s", column.getName()));
        } else {
          columnSet.add(column.getName());
        }
      }
    }
  }
596823
function validateConfigSchema(config, source = null) {
    validateSchema = validateSchema || ajv.compile(configSchema);

    if (!validateSchema(config)) {
        throw new Error(`ESLint configuration in ${source} is invalid:\n${formatErrors(validateSchema.errors)}`);
    }

    if (Object.hasOwnProperty.call(config, "ecmaFeatures")) {
        emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES");
    }
}
871141
def validate(obj, schema):
        
        if isinstance(obj, str):
            obj = json.loads(obj)
        return JsonValidator(schema)._validate(obj)
2097
function validate (data, schema) {
  if (!data || !schema) {
    throw new Error('Trying to validate without passing data and schema')
  }
  return Joi.validate(data, schema)
}
541923
function compile(schema, _meta) {
  var schemaObj = this._addSchema(schema, undefined, _meta);
  return schemaObj.validate || this._compile(schemaObj);
}
457549
def special_validate(data, schema):
    
    jsonschema.validate(data, schema)
    data['special'] = str(data['name'] == 'Garfield').lower()
75495
def validate(document, schema, log_qualifier = True):
    
    if isinstance(schema, ValidatorNode):
        if not validate(document, schema.content):
            return False
        if not schema.validator(document, schema.content):
            if log_qualifier:
                LOG.error("%r failed to validate with qualifier %s", document, schema.validator.__name__)
            return False
        return True
    elif isinstance(schema, dict):
        if not isinstance(document, dict):
            LOG.error("wanted a dictionary, got a %s", document.__class__.__name__)
            return False
        generic = []
        optional = {}
        optionalnull = {}
        mandatory = []
        for key, schema_val in schema.iteritems():
            if isinstance(key, ValidatorNode):
                if key.mode == 'mandatory':
                    mandatory.append((key, schema_val))
                else:
                    generic.append((key, schema_val))
            elif isinstance(schema_val, Optional):
                optional[key] = schema_val
            elif isinstance(schema_val, OptionalNull):
                optional[key] = schema_val
                optionalnull[key] = True
            else:
                mandatory.append((key, schema_val))

        doc_copy = document.copy()

        for key, schema_val in mandatory:
            if isinstance(key, ValidatorNode):
                nb = 0
                rm = []
                for doc_key, doc_val in doc_copy.iteritems():
                    if not validate(doc_key, key, False):
                        continue

                    nb += 1

                    if validate(doc_val, schema_val):
                        rm.append(doc_key)
                    else:
                        return False

                if nb == 0:
                    LOG.error("missing document %r for qualifier: %r", key.content, key.validator.__name__)
                    return False
                elif key.min is not None and nb < key.min:
                    LOG.error("no enough document %r for qualifier: %r (min: %r, found: %r)", key.content, key.validator.__name__, key.min, nb)
                    return False
                elif key.max is not None and nb > key.max:
                    LOG.error("too many document %r for qualifier: %r (max: %r, found: %r)", key.content, key.validator.__name__, key.max, nb)
                    return False
                else:
                    for x in rm:
                        del doc_copy[x]
                    continue

            doc_val = doc_copy.get(key, Nothing)
            if doc_val is Nothing:
                LOG.error("missing key %r in document", key)
                return False

            if helpers.is_scalar(schema_val):
                if not validate(doc_val, schema_val):
                    return False
                del doc_copy[key]
                continue

            if schema_val.modifier:
                for modname in schema_val.modifier:
                    if modname in _modifiers:
                        document[key] = _modifiers[modname](document[key])
                        doc_val = _modifiers[modname](doc_val)
                    elif hasattr(doc_val, modname):
                        document[key] = getattr(document[key], modname)()
                        doc_val = getattr(doc_val, modname)()

            if _valid_len(key, doc_val, schema_val.min_len, schema_val.max_len) is False:
                return False
            if not validate(doc_val, schema_val.content):
                return False
            del doc_copy[key]

        for key, schema_val in generic:
            nb = 0
            rm = []

            for doc_key, doc_val in doc_copy.iteritems():
                if not validate(doc_key, key, False):
                    continue

                nb += 1

                if validate(doc_val, schema_val):
                    rm.append(doc_key)
                else:
                    return False

            if key.min is not None and nb < key.min:
                LOG.error("no enough document %r for qualifier: %r (min: %r, found: %r)", key.content, key.validator.__name__, key.min, nb)
                return False
            elif key.max is not None and nb > key.max:
                LOG.error("too many document %r for qualifier: %r (max: %r, found: %r)", key.content, key.validator.__name__, key.max, nb)
                return False
            else:
                for x in rm:
                    del doc_copy[x]
                continue

        for key, doc_val in doc_copy.iteritems():
            schema_val = optional.get(key, Nothing)
            if schema_val is Nothing:
                LOG.error("forbidden key %s in document", key)
                return False
            elif optionalnull.has_key(key) and doc_val is None:
                continue
            elif schema_val.min_len == 0 and doc_val is "":
                continue

            if schema_val.modifier:
                for modname in schema_val.modifier:
                    if modname in _modifiers:
                        document[key] = _modifiers[modname](document[key])
                        doc_val = _modifiers[modname](doc_val)
                    elif hasattr(doc_val, modname):
                        document[key] = getattr(document[key], modname)()
                        doc_val = getattr(doc_val, modname)()
                if optionalnull.has_key(key) and doc_val is None:
                    continue
                elif schema_val.min_len == 0 and doc_val is "":
                    continue

            if _valid_len(key, doc_val, schema_val.min_len, schema_val.max_len) is False:
                return False
            if not validate(doc_val, schema_val.content):
                return False
        return True
    elif isinstance(schema, list):
        if not isinstance(document, list):
            LOG.error("wanted a list, got a %s", document.__class__.__name__)
        for elt in document:
            # XXX: give a meaning when there are multiple element in a sequence of a schema?
            if len(schema) < 2:
                if not validate(elt, schema[0]):
                    return False
            elif isinstance(schema[0], dict):
                tmp = {}
                for x in schema:
                    for key, val in x.iteritems():
                        tmp[key] = val
                if not validate(elt, tmp):
                    return False
            else:
                if not validate(elt, schema[0]):
                    return False
        return True
    elif isinstance(schema, Any):
        return True
    elif isinstance(schema, Scalar):
        return helpers.is_scalar(document)
    else: # scalar
        if isinstance(schema, str):
            schema = unicode(schema)
        if isinstance(document, str):
            document = unicode(document, 'utf8')
        if schema.__class__ != document.__class__:
            LOG.error("wanted a %s, got a %s", schema.__class__.__name__, document.__class__.__name__)
            return False
        return True
461387
def validate_schema(schema_name):
    """"""
    def decorator(f):
        @wraps(f)
        def wrapper(*args, **kw):
            instance = args[0]
            try:
                instance.validator(instance.schemas[schema_name]).validate(request.get_json())
            except ValidationError, e:
                ret_dict = instance._create_ret_object(instance.FAILURE,
                                                       None, True,
                                                       instance.BAD_SCHEMA,
                                                       e.message)
                instance.logger.error("Invalid Schema", ret_dict)
                return jsonify(ret_dict), 400
            instance.logger.debug("Schema is valid")
            return f(*args, **kw)
        return wrapper
    return decorator
334397
function validateArgs (args, methodMeta) {
    // do not validate if no schema
    if (!defined(methodMeta.schema.args)) {
        return args
    }
    // do not validate if disabled
    if (!methodMeta.validateArgs) {
        return args
    }
    // get validator
    var ajv = methodMeta.ajv
    // throw error if validation fails
    if (!ajv.validate(methodMeta.schema.args.id, args)) {
        // create error
        var error = new Error(`${methodMeta.signature}: invalid args - ${ajv.errorsText()}`)
        // add ajv errors to error data
        error.data = ajv.errors
        // throw error
        throw error
    }
    // return possibly modified args
    return args
}
884795
def validate(instance):
    

    jsonschema.validate(
        to_dict(instance, dict_type=dict), build_schema(instance.__class__)
    )
856978
public void validate(Schema schema) {
        if (queryCondition != null || filterCondition != null) {
            query(schema, null);
        }
        if (sort != null) {
            sort.sort(schema);
        }
    }
1473
public function validate($schema = '')
    {
        //You know sometimes you think you have enough time, but it is not always true ...
        //(timeout in hudson with the generis-hard test suite)
        helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::MEDIUM);
        
        $content = $this->getContent();
        if (!empty($content)) {
            try {
                libxml_use_internal_errors(true);

                $dom = new DomDocument();
                $dom->formatOutput = true;
                $dom->preserveWhiteSpace = false;
                
                $this->valid = $dom->loadXML($content);

                if ($this->valid && !empty($schema)) {
                    $this->valid = $dom->schemaValidate($schema);
                }

                if (!$this->valid) {
                    $this->addErrors(libxml_get_errors());
                }
                libxml_clear_errors();
            } catch(DOMException $de) {
                $this->addError($de);
            }
        }
        
        
        helpers_TimeOutHelper::reset();
        return (bool) $this->valid;
    }
1160999
def assert_valid_schema(schema: GraphQLSchema) -> None:
    
    errors = validate_schema(schema)
    if errors:
        raise TypeError("\n\n".join(error.message for error in errors))
152240
def _validate_schema(self):
        
        try:
            log.debug("validating provider schema")
            self.validator.check_schema(self.schema)
        except jsonschema.SchemaError as e:
            raise SchemaError(
                schema_error=e.message, provider=self.name, data=self.schema
            )