ValidationError
A validation error.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace NJsonSchema.Validation
{
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; }
public JsonSchema Schema { get; set; }
public ValidationError(ValidationErrorKind errorKind, string propertyName, string propertyPath, JToken token, JsonSchema schema)
{
Kind = errorKind;
Property = propertyName;
Path = ((propertyPath != null) ? ("#/" + propertyPath) : "#");
HasLineInfo = (((IJsonLineInfo)token)?.HasLineInfo() ?? false);
if (HasLineInfo) {
LineNumber = ((IJsonLineInfo)token).LineNumber;
LinePosition = ((IJsonLineInfo)token).LinePosition;
} else {
LineNumber = 0;
LinePosition = 0;
}
Schema = schema;
}
public override string ToString()
{
return string.Format("{0}: {1}", new object[2] {
Kind,
Path
});
}
}
}