예제 #1
0
        private void ValidateString(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            JsonSchema schema = report.Schema;

            if (!TestType(report, JsonSchemaType.String))
                return;

            string value = _reader.Value.ToString();

            if (schema.MaximumLength != null || schema.MinimumLength != null)
            {
                int[] unicodeString = StringInfo.ParseCombiningCharacters(value);

                if (schema.MaximumLength != null && unicodeString.Length > schema.MaximumLength)
                    RaiseError("String '{0}' exceeds maximum length of {1}.".FormatWith(CultureInfo.InvariantCulture, value, schema.MaximumLength), report);

                if (schema.MinimumLength != null && unicodeString.Length < schema.MinimumLength)
                    RaiseError("String '{0}' is less than minimum length of {1}.".FormatWith(CultureInfo.InvariantCulture, value, schema.MinimumLength), report);
            }

            if (schema.Pattern != null)
            {
                if (!Regex.IsMatch(value, schema.Pattern))
                    RaiseError("String '{0}' does not match regex pattern '{1}'.".FormatWith(CultureInfo.InvariantCulture, value, schema.Pattern), report);
            }
        }
예제 #2
0
        private bool ValidateArray(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return true;

            return (TestType(report, JsonSchemaType.Array));
        }
예제 #3
0
        private bool ValidateObject(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return true;

            return (TestType(report, JsonSchemaType.Object));
        }
        private void ValidateEndObject(SchemaReport report)
        {
            if (report == null || report.Schema == null)
            {
                return;
            }

            JsonSchema schema = report.Schema;

            if (schema.Required != null)
            {
                List <string> unmatchedRequiredProperties = schema.Required.Except(_currentScope.LocatedProperties, StringComparer.Ordinal).ToList();

                if (unmatchedRequiredProperties.Count > 0)
                {
                    RaiseError("Required properties are missing from object: {0}.".FormatWith(CultureInfo.InvariantCulture, string.Join(", ", unmatchedRequiredProperties.ToArray())), report);
                }
            }

            int objectPropertyCount = _currentScope.TotalPropertyCount;

            if (schema.MaximumProperties != null && objectPropertyCount > schema.MaximumProperties)
            {
                RaiseError("Property count {0} exceeds maximum count of {1}.".FormatWith(CultureInfo.InvariantCulture, objectPropertyCount, schema.MaximumProperties), report);
            }

            if (schema.MinimumProperties != null && objectPropertyCount < schema.MinimumProperties)
            {
                RaiseError("Property count {0} is less than minimum count of {1}.".FormatWith(CultureInfo.InvariantCulture, objectPropertyCount, schema.MinimumProperties), report);
            }
        }
        private void ValidatePropertyName(SchemaReport report)
        {
            if (report == null || report.Schema == null)
            {
                return;
            }

            JsonSchema schema = report.Schema;

            string propertyName = Convert.ToString(_reader.Value, CultureInfo.InvariantCulture);

            if (!_currentScope.LocatedProperties.Contains(propertyName, StringComparer.Ordinal))
            {
                _currentScope.LocatedProperties.Add(propertyName);
            }

            if (!schema.AllowAdditionalProperties)
            {
                bool propertyDefinied = IsPropertyDefinied(schema, propertyName);

                if (!propertyDefinied)
                {
                    RaiseError("Property '{0}' has not been defined and the schema does not allow additional properties.".FormatWith(CultureInfo.InvariantCulture, propertyName), report);
                }
            }

            _currentScope.CurrentPropertyName = propertyName;
        }
예제 #6
0
        private void ValidateNull(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            if (!TestType(report, JsonSchemaType.Null))
                return;
        }
예제 #7
0
        private bool TestType(SchemaReport report, JsonSchemaType currentType)
        {
            if (!JsonSchemaGenerator.HasFlag(report.Schema.Type, currentType))
            {
                RaiseError("Invalid type. Expected {0} but got {1}.".FormatWith(CultureInfo.InvariantCulture, report.Schema.Type, currentType), report);
                return false;
            }

            return true;
        }
예제 #8
0
 public SchemaReport(JsonSchema schema, IList<JsonSchemaException> messages, SchemaConditionType type, SchemaReport parent, string conditionalPropertyName)
 {
     Schema = schema;
     Messages = messages;
     ConditionType = type;
     ConditionalPropertyName = conditionalPropertyName;
     SubResults = new List<SchemaReport>();
     if (parent != null && parent.Messages != null)
         Parent = parent;
 }
        private void ValidateBoolean(SchemaReport report)
        {
            if (report == null || report.Schema == null)
            {
                return;
            }

            if (!TestType(report, JsonSchemaType.Boolean))
            {
                return;
            }
        }
예제 #10
0
        //
        // CONSTRUCTOR
        //
        public TabbedDocumentSchemaReport()
        {
            InitializeComponent();

            // Load Schema Report
            this._schemaReport              = new SchemaReport();
            this._schemaReport.Invalidated += new EventHandler <EventArgs>(this.Report_Invalidated);

            // Tab Properties
            this.Text     = "Schema Report";
            this.TabImage = Resources.BITMAP_SCHEMA_REPORT;
        }
예제 #11
0
        private void ValidateInteger(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            JsonSchema schema = report.Schema;

            if (!TestType(report, JsonSchemaType.Integer))
                return;

            object value = _reader.Value;

            if (schema.Maximum != null)
            {
                if (JValue.Compare(JTokenType.Integer, value, schema.Maximum) > 0)
                    RaiseError("Integer {0} exceeds maximum value of {1}.".FormatWith(CultureInfo.InvariantCulture, value, schema.Maximum), report);
                if (schema.ExclusiveMaximum != null && (bool)schema.ExclusiveMaximum && JValue.Compare(JTokenType.Integer, value, schema.Maximum) == 0)
                    RaiseError("Integer {0} equals maximum value of {1} and exclusive maximum is true.".FormatWith(CultureInfo.InvariantCulture, value, schema.Maximum), report);
            }

            if (schema.Minimum != null)
            {
                if (JValue.Compare(JTokenType.Integer, value, schema.Minimum) < 0)
                    RaiseError("Integer {0} is less than minimum value of {1}.".FormatWith(CultureInfo.InvariantCulture, value, schema.Minimum), report);
                if (schema.ExclusiveMinimum != null && (bool)schema.ExclusiveMinimum && JValue.Compare(JTokenType.Integer, value, schema.Minimum) == 0)
                    RaiseError("Integer {0} equals minimum value of {1} and exclusive minimum is true.".FormatWith(CultureInfo.InvariantCulture, value, schema.Minimum), report);
            }

            if (schema.MultipleOf != null)
            {
                bool notMultiple = false;
            #if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
                if (value is BigInteger)
                {
                    // not that this will lose any decimal point on MultipleOf
                    // so manually raise an error if MultipleOf is not an integer and value is not zero
                    BigInteger i = (BigInteger)value;
                    bool multipleNonInteger = !Math.Abs(schema.MultipleOf.Value - Math.Truncate(schema.MultipleOf.Value)).Equals(0);
                    if (multipleNonInteger)
                        notMultiple = i != 0;
                    else
                        notMultiple = i % new BigInteger(schema.MultipleOf.Value) != 0;
                }
                else
            #endif
                    notMultiple = !IsZero(Convert.ToInt64(value, CultureInfo.InvariantCulture) % schema.MultipleOf.Value);

                if (notMultiple)
                    RaiseError("Integer {0} is not a multiple of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.MultipleOf), report);
            }
        }
        private void ValidateFloat(SchemaReport report)
        {
            if (report == null || report.Schema == null)
            {
                return;
            }

            JsonSchema schema = report.Schema;

            if (!TestType(report, JsonSchemaType.Float))
            {
                return;
            }

            double value = Convert.ToDouble(_reader.Value, CultureInfo.InvariantCulture);

            if (schema.Maximum != null)
            {
                if (value > schema.Maximum)
                {
                    RaiseError("Float {0} exceeds maximum value of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.Maximum), report);
                }
                if (schema.ExclusiveMaximum != null && (bool)schema.ExclusiveMaximum && value == schema.Maximum)
                {
                    RaiseError("Float {0} equals maximum value of {1} and exclusive maximum is true.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.Maximum), report);
                }
            }

            if (schema.Minimum != null)
            {
                if (value < schema.Minimum)
                {
                    RaiseError("Float {0} is less than minimum value of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.Minimum), report);
                }
                if (schema.ExclusiveMinimum != null && (bool)schema.ExclusiveMinimum && value == schema.Minimum)
                {
                    RaiseError("Float {0} equals minimum value of {1} and exclusive minimum is true.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.Minimum), report);
                }
            }

            if (schema.MultipleOf != null)
            {
                double remainder = FloatingPointRemainder(value, schema.MultipleOf.Value);

                if (!IsZero(remainder))
                {
                    RaiseError("Float {0} is not a multiple of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.MultipleOf), report);
                }
            }
        }
예제 #13
0
        private void RaiseError(string message, SchemaReport report)
        {
            IJsonLineInfo lineInfo = this;

            string exceptionMessage = (lineInfo.HasLineInfo())
                ? message + " Line {0}, position {1}.".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition)
                : message;

            JsonSchemaException ex = new JsonSchemaException(exceptionMessage, null, Path, lineInfo.LineNumber, lineInfo.LinePosition);

            if (report != null && report.Messages != null)
                report.Messages.Add(ex);
            else
                OnValidationEvent(ex);
        }
예제 #14
0
        private void ValidateEndArray(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            JsonSchema schema = report.Schema;

            int arrayItemCount = _currentScope.ArrayItemCount;

            if (schema.MaximumItems != null && arrayItemCount > schema.MaximumItems)
                RaiseError("Array item count {0} exceeds maximum count of {1}.".FormatWith(CultureInfo.InvariantCulture, arrayItemCount, schema.MaximumItems), report);

            if (schema.MinimumItems != null && arrayItemCount < schema.MinimumItems)
                RaiseError("Array item count {0} is less than minimum count of {1}.".FormatWith(CultureInfo.InvariantCulture, arrayItemCount, schema.MinimumItems), report);
        }
예제 #15
0
        private void AddConditionalSchemas(IList<SchemaReport> currentSchemas, IList<JsonSchema> schemaSet, SchemaConditionType resultType, SchemaReport parentResultSet)
        {
            if (schemaSet != null)
            {
                SchemaReport resultSet = new SchemaReport(null, new List<JsonSchemaException>(), resultType, parentResultSet, string.Empty);
                parentResultSet.SubResults.Add(resultSet);

                foreach (JsonSchema schema in schemaSet)
                {
                    SchemaReport childResultSet = new SchemaReport(schema, new List<JsonSchemaException>(), SchemaConditionType.Schema, resultSet, string.Empty);
                    currentSchemas.Add(childResultSet);
                    resultSet.SubResults.Add(childResultSet);
                    AddConditionalSchemas(currentSchemas, schema, childResultSet);
                }
            }
        }
예제 #16
0
 private void AddConditionalSchemas(IList<SchemaReport> currentSchemas, JsonSchema schema, SchemaReport parentResultSet)
 {
     AddConditionalSchemas(currentSchemas, schema.AllOf, SchemaConditionType.AllOf, parentResultSet);
     AddConditionalSchemas(currentSchemas, schema.OneOf, SchemaConditionType.OneOf, parentResultSet);
     AddConditionalSchemas(currentSchemas, schema.AnyOf, SchemaConditionType.AnyOf, parentResultSet);
     if (schema.NotOf != null)
     {
         AddConditionalSchemas(currentSchemas, new List<JsonSchema> { schema.NotOf }, SchemaConditionType.NotOf, parentResultSet);
     }
     if (schema.Dependencies != null)
     {
         foreach (KeyValuePair<string, JsonSchema> dep in schema.Dependencies)
         {
             SchemaReport childResultSet = new SchemaReport(dep.Value, new List<JsonSchemaException>(), SchemaConditionType.Dependency, parentResultSet, dep.Key);
             currentSchemas.Add(childResultSet);
             parentResultSet.SubResults.Add(childResultSet);
             AddConditionalSchemas(currentSchemas, dep.Value, childResultSet);
         }
     }
 }
        private bool TestType(SchemaReport report, JsonSchemaType currentType)
        {
            if (!JsonSchemaGenerator.HasFlag(report.Schema.Type, currentType))
            {
                RaiseError("Invalid type. Expected {0} but got {1}.".FormatWith(CultureInfo.InvariantCulture, report.Schema.Type, currentType), report);
                return false;
            }

            return true;
        }
        private void ValidateEndArray(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            JsonSchema schema = report.Schema;

            int arrayItemCount = _currentScope.ArrayItemCount;

            if (schema.MaximumItems != null && arrayItemCount > schema.MaximumItems)
                RaiseError("Array item count {0} exceeds maximum count of {1}.".FormatWith(CultureInfo.InvariantCulture, arrayItemCount, schema.MaximumItems), report);

            if (schema.MinimumItems != null && arrayItemCount < schema.MinimumItems)
                RaiseError("Array item count {0} is less than minimum count of {1}.".FormatWith(CultureInfo.InvariantCulture, arrayItemCount, schema.MinimumItems), report);
        }
 public SchemaReport(JsonSchema schema, IList<JsonSchemaException> messages, SchemaConditionType type, SchemaReport parent, string conditionalPropertyName)
 {
     Schema = schema;
     Messages = messages;
     ConditionType = type;
     ConditionalPropertyName = conditionalPropertyName;
     SubResults = new List<SchemaReport>();
     if (parent != null && parent.Messages != null)
         Parent = parent;
 }
 private void AddConditionalSchemas(IList<SchemaReport> currentSchemas, JsonSchema schema, SchemaReport parentResultSet)
 {
     AddConditionalSchemas(currentSchemas, schema.AllOf, SchemaConditionType.AllOf, parentResultSet);
     AddConditionalSchemas(currentSchemas, schema.OneOf, SchemaConditionType.OneOf, parentResultSet);
     AddConditionalSchemas(currentSchemas, schema.AnyOf, SchemaConditionType.AnyOf, parentResultSet);
     if (schema.NotOf != null)
     {
         AddConditionalSchemas(currentSchemas, new List<JsonSchema> { schema.NotOf }, SchemaConditionType.NotOf, parentResultSet);
     }
     if (schema.Dependencies != null)
     {
         foreach (KeyValuePair<string, JsonSchema> dep in schema.Dependencies)
         {
             SchemaReport childResultSet = new SchemaReport(dep.Value, new List<JsonSchemaException>(), SchemaConditionType.Dependency, parentResultSet, dep.Key);
             currentSchemas.Add(childResultSet);
             parentResultSet.SubResults.Add(childResultSet);
             AddConditionalSchemas(currentSchemas, dep.Value, childResultSet);
         }
     }
 }
        private void ValidateBoolean(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            if (!TestType(report, JsonSchemaType.Boolean))
                return;
        }
        private void ValidateString(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            JsonSchema schema = report.Schema;

            if (!TestType(report, JsonSchemaType.String))
                return;

            string value = _reader.Value.ToString();

            if (schema.MaximumLength != null || schema.MinimumLength != null)
            {
                int[] unicodeString = StringInfo.ParseCombiningCharacters(value);

                if (schema.MaximumLength != null && unicodeString.Length > schema.MaximumLength)
                    RaiseError("String '{0}' exceeds maximum length of {1}.".FormatWith(CultureInfo.InvariantCulture, value, schema.MaximumLength), report);

                if (schema.MinimumLength != null && unicodeString.Length < schema.MinimumLength)
                    RaiseError("String '{0}' is less than minimum length of {1}.".FormatWith(CultureInfo.InvariantCulture, value, schema.MinimumLength), report);
            }

            if (schema.Pattern != null)
            {
                if (!Regex.IsMatch(value, schema.Pattern))
                    RaiseError("String '{0}' does not match regex pattern '{1}'.".FormatWith(CultureInfo.InvariantCulture, value, schema.Pattern), report);
            }
        }
        private void AddConditionalSchemas(IList<SchemaReport> currentSchemas, IList<JsonSchema> schemaSet, SchemaConditionType resultType, SchemaReport parentResultSet)
        { 
            if (schemaSet != null)
            {
                SchemaReport resultSet = new SchemaReport(null, new List<JsonSchemaException>(), resultType, parentResultSet, string.Empty);
                parentResultSet.SubResults.Add(resultSet);

                foreach (JsonSchema schema in schemaSet)
                {
                    SchemaReport childResultSet = new SchemaReport(schema, new List<JsonSchemaException>(), SchemaConditionType.Schema, resultSet, string.Empty);
                    currentSchemas.Add(childResultSet);
                    resultSet.SubResults.Add(childResultSet);
                    AddConditionalSchemas(currentSchemas, schema, childResultSet);
                }
            }
        }
        private void ValidateEndObject(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            JsonSchema schema = report.Schema;

            if (schema.Required != null)
            {
                List<string> unmatchedRequiredProperties = schema.Required.Except(_currentScope.LocatedProperties, StringComparer.Ordinal).ToList();

                if (unmatchedRequiredProperties.Count > 0)
                    RaiseError("Required properties are missing from object: {0}.".FormatWith(CultureInfo.InvariantCulture, string.Join(", ", unmatchedRequiredProperties.ToArray())), report);
            }

            int objectPropertyCount = _currentScope.TotalPropertyCount;

            if (schema.MaximumProperties != null && objectPropertyCount > schema.MaximumProperties)
                RaiseError("Property count {0} exceeds maximum count of {1}.".FormatWith(CultureInfo.InvariantCulture, objectPropertyCount, schema.MaximumProperties), report);

            if (schema.MinimumProperties != null && objectPropertyCount < schema.MinimumProperties)
                RaiseError("Property count {0} is less than minimum count of {1}.".FormatWith(CultureInfo.InvariantCulture, objectPropertyCount, schema.MinimumProperties), report);
        }
        private bool ValidateObject(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return true;

            return (TestType(report, JsonSchemaType.Object));
        }
        private bool ValidateArray(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return true;

            return (TestType(report, JsonSchemaType.Array));
        }
        private void ValidatePropertyName(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            JsonSchema schema = report.Schema;

            string propertyName = Convert.ToString(_reader.Value, CultureInfo.InvariantCulture);

            if (!_currentScope.LocatedProperties.Contains(propertyName, StringComparer.Ordinal))
                _currentScope.LocatedProperties.Add(propertyName);

            if (!schema.AllowAdditionalProperties)
            {
                bool propertyDefinied = IsPropertyDefinied(schema, propertyName);

                if (!propertyDefinied)
                    RaiseError("Property '{0}' has not been defined and the schema does not allow additional properties.".FormatWith(CultureInfo.InvariantCulture, propertyName), report);
            }

            _currentScope.CurrentPropertyName = propertyName;
        }
        private void ValidateFloat(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            JsonSchema schema = report.Schema;

            if (!TestType(report, JsonSchemaType.Float))
                return;

            double value = Convert.ToDouble(_reader.Value, CultureInfo.InvariantCulture);

            if (schema.Maximum != null)
            {
                if (value > schema.Maximum)
                    RaiseError("Float {0} exceeds maximum value of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.Maximum), report);
                if (schema.ExclusiveMaximum != null && (bool)schema.ExclusiveMaximum && value == schema.Maximum)
                    RaiseError("Float {0} equals maximum value of {1} and exclusive maximum is true.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.Maximum), report);
            }

            if (schema.Minimum != null)
            {
                if (value < schema.Minimum)
                    RaiseError("Float {0} is less than minimum value of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.Minimum), report);
                if (schema.ExclusiveMinimum != null && (bool)schema.ExclusiveMinimum && value == schema.Minimum)
                    RaiseError("Float {0} equals minimum value of {1} and exclusive minimum is true.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.Minimum), report);
            }

            if (schema.MultipleOf != null)
            {
                double remainder = FloatingPointRemainder(value, schema.MultipleOf.Value);

                if (!IsZero(remainder))
                    RaiseError("Float {0} is not a multiple of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.MultipleOf), report);
            }
        }
        private void ValidateInteger(SchemaReport report)
        {
            if (report == null || report.Schema == null)
                return;

            JsonSchema schema = report.Schema;

            if (!TestType(report, JsonSchemaType.Integer))
                return;

            object value = _reader.Value;

            if (schema.Maximum != null)
            {
                if (JValue.Compare(JTokenType.Integer, value, schema.Maximum) > 0)
                    RaiseError("Integer {0} exceeds maximum value of {1}.".FormatWith(CultureInfo.InvariantCulture, value, schema.Maximum), report);
                if (schema.ExclusiveMaximum != null && (bool)schema.ExclusiveMaximum && JValue.Compare(JTokenType.Integer, value, schema.Maximum) == 0)
                    RaiseError("Integer {0} equals maximum value of {1} and exclusive maximum is true.".FormatWith(CultureInfo.InvariantCulture, value, schema.Maximum), report);
            }

            if (schema.Minimum != null)
            {
                if (JValue.Compare(JTokenType.Integer, value, schema.Minimum) < 0)
                    RaiseError("Integer {0} is less than minimum value of {1}.".FormatWith(CultureInfo.InvariantCulture, value, schema.Minimum), report);
                if (schema.ExclusiveMinimum != null && (bool)schema.ExclusiveMinimum && JValue.Compare(JTokenType.Integer, value, schema.Minimum) == 0)
                    RaiseError("Integer {0} equals minimum value of {1} and exclusive minimum is true.".FormatWith(CultureInfo.InvariantCulture, value, schema.Minimum), report);
            }

            if (schema.MultipleOf != null)
            {
                bool notMultiple = false;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
                if (value is BigInteger)
                {
                    // not that this will lose any decimal point on MultipleOf
                    // so manually raise an error if MultipleOf is not an integer and value is not zero
                    BigInteger i = (BigInteger)value;
                    bool multipleNonInteger = !Math.Abs(schema.MultipleOf.Value - Math.Truncate(schema.MultipleOf.Value)).Equals(0);
                    if (multipleNonInteger)
                        notMultiple = i != 0;
                    else
                        notMultiple = i % new BigInteger(schema.MultipleOf.Value) != 0;
                }
                else
#endif
                    notMultiple = !IsZero(Convert.ToInt64(value, CultureInfo.InvariantCulture) % schema.MultipleOf.Value);

                if (notMultiple)
                    RaiseError("Integer {0} is not a multiple of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.MultipleOf), report);
            }
        }
        private void RaiseError(string message, SchemaReport report)
        {
            IJsonLineInfo lineInfo = this;

            string exceptionMessage = (lineInfo.HasLineInfo())
                ? message + " Line {0}, position {1}.".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition)
                : message;

            JsonSchemaException ex = new JsonSchemaException(exceptionMessage, null, Path, lineInfo.LineNumber, lineInfo.LinePosition);

            if (report != null && report.Messages != null)
                report.Messages.Add(ex);
            else
                OnValidationEvent(ex);
        }