<PackageReference Include="NJsonSchema" Version="10.1.21" />

TimeSpanFormatValidator

Validator for "TimeSpan" format.
using Newtonsoft.Json.Linq; using System; namespace NJsonSchema.Validation.FormatValidators { public class TimeSpanFormatValidator : IFormatValidator { public string Format { get; } = "time-span"; public ValidationErrorKind ValidationErrorKind { get; } = ValidationErrorKind.TimeSpanExpected; public bool IsValid(string value, JTokenType tokenType) { TimeSpan result; if (tokenType != JTokenType.TimeSpan) return TimeSpan.TryParse(value, out result); return true; } } }