Skip to content

Commit

Permalink
Merge pull request #907 from RSuter/master
Browse files Browse the repository at this point in the history
Release v9.13.19
  • Loading branch information
RicoSuter authored Feb 22, 2019
2 parents 3558d1d + efa8fa5 commit 28b87b3
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public virtual string Generate(JsonProperty property)
return ConversionUtilities.ConvertToUpperCamelCase(property.Name
.Replace("\"", string.Empty)
.Replace("@", string.Empty)
.Replace("$", string.Empty)
.Replace(".", "-")
.Replace("=", "-")
.Replace("+", "plus"), true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;net451</TargetFrameworks>
<Description>JSON Schema reader, generator and validator for .NET</Description>
<Version>9.13.18</Version>
<Version>9.13.19</Version>
<PackageTags>json schema validation generator .net</PackageTags>
<Copyright>Copyright © Rico Suter, 2018</Copyright>
<PackageLicenseUrl>https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md</PackageLicenseUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;net451</TargetFrameworks>
<Description>JSON Schema reader, generator and validator for .NET</Description>
<Version>9.13.18</Version>
<Version>9.13.19</Version>
<PackageTags>json schema validation generator .net</PackageTags>
<Copyright>Copyright © Rico Suter, 2018</Copyright>
<PackageLicenseUrl>https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md</PackageLicenseUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;net451</TargetFrameworks>
<Description>JSON Schema reader, generator and validator for .NET</Description>
<Version>9.13.18</Version>
<Version>9.13.19</Version>
<PackageTags>json schema validation generator .net</PackageTags>
<Copyright>Copyright © Rico Suter, 2018</Copyright>
<PackageLicenseUrl>https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md</PackageLicenseUrl>
Expand Down
32 changes: 32 additions & 0 deletions src/NJsonSchema.Tests/Validation/SchemaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,5 +379,37 @@ public async Task When_multiple_types_fail_with_errors_take_the_best_group()
Assert.Equal(1, errors.Count);
Assert.Contains(errors, e => e.Kind == ValidationErrorKind.NoTypeValidates);
}

[Fact]
public async Task When_datetime_with_regex_validation_then_datetime_is_not_altered()
{
//// Arrange
var schemaJson = @"
{
""$schema"": ""http://json-schema.org/draft-07/schema#"",
""type"": ""object"",
""required"": [
""my_datetime""
],
""properties"": {
""my_datetime"": {
""type"": ""string"",
""pattern"": ""^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$""
}
}
}";

var json = @"
{
""my_datetime"": ""2018-12-19T16:58:07.270Z""
}";

//// Act
var schema = await JsonSchema4.FromJsonAsync(schemaJson);
var errors = schema.Validate(json);

//// Assert
Assert.Equal(0, errors.Count);
}
}
}
2 changes: 1 addition & 1 deletion src/NJsonSchema.Yaml/NJsonSchema.Yaml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;net45</TargetFrameworks>
<Description>JSON Schema reader, generator and validator for .NET</Description>
<Version>9.13.18</Version>
<Version>9.13.19</Version>
<PackageTags>json schema validation generator .net</PackageTags>
<Copyright>Copyright © Rico Suter, 2018</Copyright>
<PackageLicenseUrl>https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md</PackageLicenseUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/NJsonSchema/NJsonSchema.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.0;netstandard2.0;net40;net45</TargetFrameworks>
<Description>JSON Schema reader, generator and validator for .NET</Description>
<Version>9.13.18</Version>
<Version>9.13.19</Version>
<PackageTags>json schema validation generator .net</PackageTags>
<Copyright>Copyright © Rico Suter, 2018</Copyright>
<PackageLicenseUrl>https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md</PackageLicenseUrl>
Expand Down
12 changes: 10 additions & 2 deletions src/NJsonSchema/Validation/JsonSchemaValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
Expand Down Expand Up @@ -52,8 +53,15 @@ public JsonSchemaValidator()
/// <returns>The list of validation errors.</returns>
public ICollection<ValidationError> Validate(string jsonData, JsonSchema4 schema)
{
var jsonObject = JToken.Parse(jsonData);
return Validate(jsonObject, schema);
using (var reader = new StringReader(jsonData))
using (var jsonReader = new JsonTextReader(reader)
{
DateParseHandling = DateParseHandling.None
})
{
var jsonObject = JToken.ReadFrom(jsonReader);
return Validate(jsonObject, schema);
}
}

/// <summary>Validates the given JSON token.</summary>
Expand Down

0 comments on commit 28b87b3

Please sign in to comment.