Run through a schema and a data structure,
        validating along the way.

        Ignores fields that are in the data structure, but not in the schema.

        Returns an array of errors.
964887
def _validate(self, validator, data, key, position=None, includes=None):
        
        errors = []

        if position:
            position = '%s.%s' % (position, key)
        else:
            position = key

        try:  # Pull value out of data. Data can be a map or a list/sequence
            data_item = util.get_value(data, key)
        except KeyError:  # Oops, that field didn't exist.
            if validator.is_optional:  # Optional? Who cares.
                return errors
            # SHUT DOWN EVERTYHING
            errors.append('%s: Required field missing' % position)
            return errors

        return self._validate_item(validator, data_item, position, includes)
1290931
def validate()
       failed = []
        
        @loaded_schema['sections'].each{
          |section|
          
          #check required sections are there
          if (section['required'] && !@loaded_file.has_key?(section['name']))
            @errors.push('Error: missing required section - ' + section['name'])
            failed.push(section['name'])
          elsif @loaded_file.has_key?(section['name'])
            node = @loaded_file[section['name']]
            validated = match_node(node,section,section['name'])
            if(!validated)
              failed.push(section['name'])
            end
          end
               
        }
        
        result = {}       
        result["result"] = failed.empty?
        
        if !failed.empty? && !@errors.empty?
          result["errors"] = @errors
        end
        
        return result
      end
311227
def validate(data):
        
        try:
            return Schema(Validator.SCHEMA).validate(data)
        except SchemaError as exception:
            logging.getLogger(__name__).error(exception)
            return None
609267
def validation_schema(name):
    """"""
    schemas = {
        'processor': 'processSchema.json',
        'descriptor': 'descriptorSchema.json',
        'field': 'fieldSchema.json',
        'type': 'typeSchema.json',
    }

    if name not in schemas:
        raise ValueError()

    field_schema_file = finders.find('flow/{}'.format(schemas['field']), all=True)[0]
    with open(field_schema_file, 'r') as fn:
        field_schema = fn.read()

    if name == 'field':
        return json.loads(field_schema.replace('{{PARENT}}', ''))

    schema_file = finders.find('flow/{}'.format(schemas[name]), all=True)[0]
    with open(schema_file, 'r') as fn:
        schema = fn.read()

    return json.loads(schema.replace('{{FIELD}}', field_schema).replace('{{PARENT}}', '/field'))
871141
def validate(obj, schema):
        
        if isinstance(obj, str):
            obj = json.loads(obj)
        return JsonValidator(schema)._validate(obj)
1137421
def _validate_excludes(self, excludes, field, value):
        
        if isinstance(excludes, Hashable):
            excludes = [excludes]

        # Save required field to be checked latter
        if 'required' in self.schema[field] and self.schema[field]['required']:
            self._unrequired_by_excludes.add(field)
        for exclude in excludes:
            if (exclude in self.schema and
                'required' in self.schema[exclude] and
                    self.schema[exclude]['required']):

                self._unrequired_by_excludes.add(exclude)

        if [True for key in excludes if key in self.document]:
            # Wrap each field in `excludes` list between quotes
            exclusion_str = ', '.join("'{0}'"
                                      .format(word) for word in excludes)
            self._error(field, errors.EXCLUDES_FIELD, exclusion_str)
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
1155105
def get_field_schema_validations(field: Field) -> Dict[str, Any]:
    
    f_schema: Dict[str, Any] = {}
    if lenient_issubclass(field.type_, (str, bytes)):
        for attr_name, t, keyword in _str_types_attrs:
            attr = getattr(field.schema, attr_name, None)
            if isinstance(attr, t):
                f_schema[keyword] = attr
    if lenient_issubclass(field.type_, numeric_types) and not issubclass(field.type_, bool):
        for attr_name, t, keyword in _numeric_types_attrs:
            attr = getattr(field.schema, attr_name, None)
            if isinstance(attr, t):
                f_schema[keyword] = attr
    schema = cast('Schema', field.schema)
    if schema.extra:
        f_schema.update(schema.extra)
    return f_schema
26011
function checkProp(value, schema, path, i, errors) {
	if (!errors) { errors = []; }

	path +=
		path ? typeof i == 'number' ? '[' + i + ']'
			 : typeof i == 'undefined' ? '' : '.' + i : i;

	function addError(message) {
		errors.push({
			property: path,
			message:message
		});
	}

	var schemaType = typeof schema,
		isObject = schemaType == 'object',
		isFunction = schemaType == 'function';

	if ((!isObject || Array.isArray(schema)) && (path || !isFunction)) {
		if (isFunction) {
			if (!(value instanceof schema)) {
				addError("is not an instance of the class/constructor " + schema.name);
			}
		} else if (schema) {
			addError("Invalid schema/property definition " + schema);
		}

		return errors;
	}

	if (gCheckPropChange && schema.readonly) { addError("is a readonly field, it can not be changed"); }

	// if it extends another schema, it must pass that schema as well
	if (schema['extends']) { checkProp(value, schema['extends'], path, i, errors); }

	if (value === undefined) {
		if (!schema.optional) { addError("is missing and it is not optional"); }
	} else {
		errors = errors.concat(checkType(schema.type,value));
		if (schema.disallow && !checkType(schema.disallow,value).length) { addError(" disallowed value was matched"); }

		if (value !== null) {
			if (Array.isArray(value)) {
				if (schema.items) {
					if (Array.isArray(schema.items)) {
						for (i=0,l=value.length; i<l; i++) {
							errors.concat(checkProp(value[i],schema.items[i],path,i, errors));
						}
					} else {
						for (i=0,l=value.length; i<l; i++) {
							errors.concat(checkProp(value[i],schema.items,path,i, errors));
						}
					}
				}
				if (schema.minItems && value.length < schema.minItems) {
					addError("There must be a minimum of " + schema.minItems + " in the array");
				}
				if (schema.maxItems && value.length > schema.maxItems) {
					addError("There must be a maximum of " + schema.maxItems + " in the array");
				}
			} else if (schema.properties) {
				errors.concat(checkObj(value, schema.properties, path, schema.additionalProperties, errors));
			}
			if (schema.pattern && typeof value == 'string' && !value.match(schema.pattern)) {
				addError("does not match the regex pattern " + schema.pattern);
			}
			if (schema.maxLength && typeof value == 'string' && value.length > schema.maxLength) {
				addError("may only be " + schema.maxLength + " characters long");
			}
			if (schema.minLength && typeof value == 'string' && value.length < schema.minLength) {
				addError("must be at least " + schema.minLength + " characters long");
			}
			if (typeof schema.minimum !== undefined
					&& typeof value == typeof schema.minimum
					&& schema.minimum > value)
			{
				addError("must have a minimum value of " + schema.minimum);
			}
			if (typeof schema.maximum !== undefined
					&& typeof value == typeof schema.maximum
					&& schema.maximum < value)
			{
				addError("must have a maximum value of " + schema.maximum);
			}

			if (schema['enum']) {

				var enumer = schema['enum'],
					found;

				var l = enumer.length;
				for(var j = 0; j < l; j++) {
					if (enumer[j]===value) {
						found=1;
						break;
					}
				}

				if (!found) { addError("does not have a value in the enumeration " + enumer.join(", ")); }
			}
			if (typeof schema.maxDecimal == 'number' &&
			(value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))) {
				addError("may only have " + schema.maxDecimal + " digits of decimal places");
			}
		}
	}

	return errors;
}
1205904
def validate(self, value, add_comments=False, schema_name="map"):
        
        validator = self.get_schema_validator(schema_name)

        error_messages = []

        if isinstance(value, list):
            for d in value:
                error_messages += self._validate(d, validator, add_comments, schema_name)
        else:
            error_messages = self._validate(value, validator, add_comments, schema_name)

        return error_messages
994654
def _validated(self, data):
        """"""
        for sub in self.schemas:
            data = sub(data)
        return data
451192
function checkSchemaErrors(schemaJSON)
    {

      //check against the proper schema definition
      // var vck = self.validator.validateMultiple(schemaJSON, schemaSpec, true);
       var valCheck = self.validateFunction.apply(self.validator, [schemaJSON, schemaSpec, true]);
       
       //grab all possible errors
       var checkErrors = {length: 0};
       var checkWarnings = {length: 0};

       //if we're valid -- which we almost certainly are -- just keep going
       if(!valCheck.valid)
       {
          //let it be known -- this is a weird error
          self.log("Invalid from v4 JSON schema perspective: ", valCheck[errorKey]);

          checkErrors["root"] = valCheck[errorKey];
          checkErrors.length++;

          //not valid, throw it back
          return checkErrors;
       }


       //make sure we have some properties -- otherwise there is literally no validation/
       //during the move process, this is overridden, but it's a good check nonetheless
       if(!schemaJSON.properties && !schemaJSON.items)
       {
          checkErrors["root"] = "No properties/items defined at root. Schema has no validation without properties!";
          checkErrors.length++;
       }

       //going to need to traverse our schema object
       var tJSON = traverse(schemaJSON);

       tJSON.forEach(function(node)
       {
        //skip the root please
        if(this.isRoot || this.path.join(pathDelim).indexOf('required') != -1)
          return;

        //this should be a warning
        if(!self.requireByDefault && !this.isLeaf && !this.node.required)
        {
            //if you don't have a required object, then you're gonna have a bad time
            //this is a warning
            checkWarnings[this.path.join(pathDelim)] = "warning: if you disable requireByDefault and don't put require arrays, validation will ignore those properties.";
            checkWarnings.length++;

        }
        if(this.key == "properties" && this.node.properties)
        {
           checkErrors[this.path.join(pathDelim)] = "Properties inside properties is meaningless.";
           checkErrors.length++;
        }
        if(this.key == "type" && typeof this.node != "string")
        {
            //for whatever reason, there is a type defined, but not a string in it's place? Waa?
            checkErrors[this.path.join(pathDelim)] = "Types must be string";
            checkErrors.length++;
        }
        if(this.key == "type" && !self.typeRegExp.test(this.node.toLowerCase()))
        {
           checkErrors[this.path.join(pathDelim)] = "Types must be one of " + self.validTypes + " not " + this.node;
           checkErrors.length++;
        }
        if(this.isLeaf)
        {
          //if you don't have a type, and there is no ref object
          if(!this.parent.node.properties && (this.key != "type" && this.key != "$ref") && !this.parent.node.type && !this.parent.node["$ref"])
          {
              checkErrors[this.path.join(pathDelim)] = "Object doesn't have any properties, a valid type, or a reference, therefore it is invalid in the WIN spec.";
              checkErrors.length++;
          }
        }
        //not a leaf, you don't have a reference
        if(!self.allowAnyObjects && !this.isLeaf && !this.node["$ref"] )
        {
          //special case for items -- doesn't apply
          if(this.node.type == "object" && this.key != "items")
          {
            //we're going to check if the list of keys to follow have any non keywords
            //for instance if {type: "object", otherThing: "string"} keys = type, otherThing
            //if instead it's just {type : "object", required : []}, keys = type, required 
            //notice that the top has non-keyword keys, and the bottom example does not 
            //we're looking for the bottom example and rejecting it
            var bHasNonKeywords = hasNonKeywords(this.keys);
            
            //if you ONLY have keywords -- you don't have any other object types
            //you are a violation of win spec and you allow any object or array to be passed in
            if(!bHasNonKeywords){
              // self.log("Current: ".magenta, this.key, " Keys: ".cyan, this.keys || "none, node: " + this.node, " has non? ".red + bHasNonKeywords);
              checkErrors[this.path.join(pathDelim)] = "AllowAnyObjects is off, therefore you cannot simple have an 'object' type with no inner properties";
              checkErrors.length++;
            }
          }
          else if(this.node.type == "array")
          {
            //if you are an array and you have no items -- not allowed!
            if(!this.node.items){
              // self.log("Current: ".magenta, this.key, " Keys: ".cyan, this.keys || "none, node: " + this.node, " has non? ".red + bHasNonKeywords);
              checkErrors[this.path.join(pathDelim)] = "AllowAnyObjects is off, therefore you cannot simple have an 'array' type with no inner items";
              checkErrors.length++;
            }
            else
            {
              //if you have a ref -- you're okay for us!
              var bIemsHaveNonKey = this.node.items["$ref"] || this.node.items["type"] || hasNonKeywords(this.node.items.properties || {});
               if(!bIemsHaveNonKey){
                // self.log("Current: ".magenta, this.key, " Keys: ".cyan, this.keys || "none, node: " + this.node, " has non? ".red + bHasNonKeywords);
                checkErrors[this.path.join(pathDelim)] = "AllowAnyObjects is off, therefore you cannot simple have an 'array' type with no non-keyword inner items";
                checkErrors.length++;
              }
            }
          }
        
        }
        //if you're an array
        if(this.node.type == "array")
        {
          //grab your items
          var items = this.node.items;
          if(!items && !self.allowAnyObjects)
          {
             checkErrors[this.path.join(pathDelim)] = "AllowAnyObjects is off for arrays, therefore you cannot simple have an 'array' type with no inner items";
              checkErrors.length++;
          }
          else
          {
            items = items || {};
            //we have items -- we shouldn't have a reference type && other items
            if(items.properties && items["$ref"])
            {
              checkErrors[this.path.join(pathDelim)] = "Array items in WIN cannot have properties AND a reference type. One or the other.";
              checkErrors.length++;
            }
          }
        }


       });

       if(checkErrors.length || checkWarnings.length)
        return {errors: checkErrors, warnings: checkWarnings};
      else
        return null;

    }
122705
def check_schema_coverage(doc, schema):
    '''
    
    '''
    error_list = []
    to_delete = []
    for entry in doc.list_tuples():
        (name, value, index, seq) = entry
        temp_schema = schema_match_up(doc, schema)
        if not name in temp_schema.list_values("name"):
            error_list.append( ("[error]", "doc", seq, "a name of '{}' not found in schema".format(name)) )
            to_delete.append(seq)
        else:
            # check subs
            el = check_schema_coverage(doc[name, value, index], temp_schema["name", name])
            error_list.extend(el)
    for seq in to_delete:
        doc.seq_delete(seq)
    return error_list
474698
def validation_error_try_to_accept(err, data, schema):
    
    if not isinstance(err, ValidationError):
        abort(Response(err, status=HTTPStatus.BAD_REQUEST))

    alernative_schema = dict(schema)
    alernative_schema['properties']['running_time'].update({
        'description': "Films's running time",
        'type': 'integer',
        'example': 169
    })

    try:
        jsonschema.validate(data, alernative_schema)
    except ValidationError as err:
        abort(Response(str(err), status=400))
1339828
def _validate(self, schema):
        
        if isinstance(schema, _str_type):
            schema = self.validator.schema_registry.get(schema, schema)

        if schema is None:
            raise SchemaError(errors.SCHEMA_ERROR_MISSING)

        schema = copy(schema)
        for field in schema:
            if isinstance(schema[field], _str_type):
                schema[field] = rules_set_registry.get(schema[field],
                                                       schema[field])

        if not self.schema_validator(schema, normalize=False):
            raise SchemaError(self.schema_validator.errors)
667368
function validateModel(json, model) {
    var schemaKeys = [];
    for (var keyInSchema in model) {
      schemaKeys.push(keyInSchema);
    }
    // Check if foreing keys are allowed.
    if (!model[SCHEMAALLOWUNKNOWN]) {
      // TODO ensure that null and false enter here.
      checkUnknown(json, schemaKeys);
    }
    for (var schemaKeyI = 0; schemaKeyI < schemaKeys.length; schemaKeyI++) {
      var node = null;
      var schemaKey = schemaKeys[schemaKeyI];
      if (json[schemaKey]) {
        node = json[schemaKey];
      }
      if (!isReservedWord(schemaKey)) {
        validateNode(node, model[schemaKey], schemaKey);
      }
    }
  }
860388
def __validate_required_fields(self, document):
        
        try:
            required = set(field for field, definition in self.schema.items()
                           if self._resolve_rules_set(definition).
                           get('required') is True)
        except AttributeError:
            if self.is_child and self.schema_path[-1] == 'schema':
                raise _SchemaRuleTypeError
            else:
                raise
        required -= self._unrequired_by_excludes
        missing = required - set(field for field in document
                                 if document.get(field) is not None or
                                 not self.ignore_none_values)

        for field in missing:
            self._error(field, errors.REQUIRED_FIELD)

        # At least on field from self._unrequired_by_excludes should be
        # present in document
        if self._unrequired_by_excludes:
            fields = set(field for field in document
                         if document.get(field) is not None)
            if self._unrequired_by_excludes.isdisjoint(fields):
                for field in self._unrequired_by_excludes - fields:
                    self._error(field, errors.REQUIRED_FIELD)