ValidationError
A validation error.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Runtime.CompilerServices;
namespace NJsonSchema.Validation
{
[System.Runtime.CompilerServices.NullableContext(2)]
[System.Runtime.CompilerServices.Nullable(0)]
public class ValidationError
{
public ValidationErrorKind Kind { get; set; }
public string Property { get; set; }
public string Path { get; set; }
public bool HasLineInfo { get; set; }
public int LineNumber { get; set; }
public int LinePosition { get; set; }
[System.Runtime.CompilerServices.Nullable(1)]
[field: System.Runtime.CompilerServices.Nullable(1)]
public JsonSchema Schema {
[System.Runtime.CompilerServices.NullableContext(1)]
get;
[System.Runtime.CompilerServices.NullableContext(1)]
private set;
}
public JToken Token { get; set; }
public ValidationError(ValidationErrorKind errorKind, string propertyName, string propertyPath, JToken token, [System.Runtime.CompilerServices.Nullable(1)] JsonSchema schema)
{
Kind = errorKind;
Property = propertyName;
Path = ((propertyPath != null) ? ("#/" + propertyPath) : "#");
Token = token;
HasLineInfo = (((IJsonLineInfo)token)?.HasLineInfo() ?? false);
if (HasLineInfo) {
LineNumber = ((IJsonLineInfo)token).LineNumber;
LinePosition = ((IJsonLineInfo)token).LinePosition;
} else {
LineNumber = 0;
LinePosition = 0;
}
Schema = schema;
}
[System.Runtime.CompilerServices.NullableContext(1)]
public override string ToString()
{
return $"{Kind}""{Path}";
}
}
}