-Fixed unit test failing because of timezones
-Added IsValid overload that returns a list of error messages
This commit is contained in:
@@ -52,6 +52,25 @@ namespace Newtonsoft.Json.Schema
|
||||
return valid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the <see cref="JToken"/> is valid.
|
||||
/// </summary>
|
||||
/// <param name="source">The source <see cref="JToken"/> to test.</param>
|
||||
/// <param name="schema">The schema to test with.</param>
|
||||
/// <param name="errorMessages">When this method returns, contains any error messages generated while validating. </param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the specified <see cref="JToken"/> is valid; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public static bool IsValid(this JToken source, JsonSchema schema, out IList<string> errorMessages)
|
||||
{
|
||||
IList<string> errors = new List<string>();
|
||||
|
||||
source.Validate(schema, (sender, args) => errors.Add(args.Message));
|
||||
|
||||
errorMessages = errors;
|
||||
return (errorMessages.Count == 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the specified <see cref="JToken"/>.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user