private void ValidateObject()

in src/Json.Schema.Validation/Validator.cs [319:354]


        private void ValidateObject(JObject jObject, JsonSchema schema)
        {
            List<string> instancePropertySet = GetPropertyNames(jObject);

            if (schema.MaxProperties.HasValue &&
                instancePropertySet.Count > schema.MaxProperties.Value)
            {
                AddResult(jObject, ErrorNumber.TooManyProperties, schema.MaxProperties.Value, instancePropertySet.Count);
            }

            if (schema.MinProperties.HasValue &&
                instancePropertySet.Count < schema.MinProperties.Value)
            {
                AddResult(jObject, ErrorNumber.TooFewProperties, schema.MinProperties.Value, instancePropertySet.Count);
            }

            // Ensure required properties are present.
            if (schema.Required != null)
            {
                IEnumerable<string> missingProperties = schema.Required.Except(instancePropertySet);
                foreach (string propertyName in missingProperties)
                {
                    AddResult(jObject, ErrorNumber.RequiredPropertyMissing, propertyName);
                }
            }

            List<string> propertiesPropertySet = schema.Properties != null
                ? schema.Properties.Keys.ToList()
                : new List<string>();

            ValidateObjectPropertyNames(jObject, instancePropertySet, propertiesPropertySet, schema);

            ValidateObjectPropertyValues(jObject, instancePropertySet, propertiesPropertySet, schema);

            ValidateDependencies(jObject, schema, instancePropertySet);
        }