Skip to content

Commit

Permalink
prepare release v1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ilbertz committed Apr 11, 2016
1 parent 052f1ef commit 4fbe395
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 36 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.1.4 - 2016-04-11
- Future and past validation attributes added
- Moved the source to src folder

## 1.1.3 - 2016-02-22
- Fixed bug with multiple resource files
- Rename ValdrType/ValdrMember to ...Attribute
Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PM> Install-Package Nca.Valdr

In Visual Studio, right-click your project and under Properties/Build Events add the following Post-build event:
```Batchfile
$(SolutionDir)packages\Nca.Valdr.1.1.3\tools\Nca.Valdr.Console.exe -i:$(TargetDir)$(TargetFileName) -o:$(ProjectDir)app\app.valdr.js
$(SolutionDir)packages\Nca.Valdr.1.1.4\tools\Nca.Valdr.Console.exe -i:$(TargetDir)$(TargetFileName) -o:$(ProjectDir)app\app.valdr.js
```

Nca.Valdr.exe accepts the following parameters:
Expand All @@ -58,20 +58,19 @@ This will add the core library to your project, which brings with it the parser

```csharp

public class ConstraintsController : Controller
public class ConstraintsController : ApiController
{
private readonly IParser _constraintParser;

public ConstraintsController(IParser constraintParser)
public ConstraintsController()
{
_constraintParser = constraintParser;
_constraintParser = new Parser();
}

[Route("/api/Constraints")]
[ResponseCache(Duration = 600)]
public IActionResult Index()
[HttpGet]
public JObject Index()
{
JObject constraints = _constraintParser.Parse(
return _constraintParser.Parse(
//optional culture (for resolving validation messages from resource files)
CultureInfo.CurrentCulture,
//optional namespace filter - StartsWith search
Expand All @@ -83,8 +82,6 @@ This will add the core library to your project, which brings with it the parser
//assembly(s) to parse for constraint generation
Assembly.GetAssembly(typeof (MyDTO))
);

return new ObjectResult(constraints);
}
}
```
Expand Down Expand Up @@ -125,8 +122,8 @@ The [.NET DataAnnotations](https://msdn.microsoft.com/en-us/library/system.compo
| [StringLength](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.stringlengthattribute%28v=vs.110%29.aspx) | [size](https://github.com/netceteragroup/valdr#size) | |
| | [digits](https://github.com/netceteragroup/valdr#digits) | unsupported |
| [RegularExpression](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.regularexpressionattribute%28v=vs.110%29.aspx) | [pattern](https://github.com/netceteragroup/valdr#partern) | |
| | [future](https://github.com/netceteragroup/valdr#future--past) | unsupported |
| | [past](https://github.com/netceteragroup/valdr#future--past) | unsupported |
| Future | [future](https://github.com/netceteragroup/valdr#future--past) | Nca.Valdr namespace |
| Past | [past](https://github.com/netceteragroup/valdr#future--past) | Nca.Valdr namespace |
| [EmailAddress](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.emailaddressattribute%28v=vs.110%29.aspx) |[email](https://github.com/netceteragroup/valdr#email) | |
| [URL](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.urlattribute%28v=vs.110%29.aspx) |[url](https://github.com/netceteragroup/valdr#url) | |

Expand Down
2 changes: 1 addition & 1 deletion src/Nca.Valdr.Core.Nuget/Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Nca.Valdr.Core</id>
<version>1.1.3</version>
<version>1.1.4</version>
<title>valdr .NET Validator Core</title>
<authors>Netcetera, Alex Ullrich</authors>
<owners>ilbertz</owners>
Expand Down
Binary file modified src/Nca.Valdr.Core.Nuget/lib/Nca.Valdr.dll
Binary file not shown.
10 changes: 10 additions & 0 deletions src/Nca.Valdr.Core.Nuget/lib/Nca.Valdr.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Nca.Valdr.Nuget/Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Nca.Valdr</id>
<version>1.1.3</version>
<version>1.1.4</version>
<title>valdr .NET Validator</title>
<authors>Netcetera</authors>
<owners>ilbertz</owners>
Expand Down
Binary file modified src/Nca.Valdr.Nuget/lib/Nca.Valdr.Console.exe
Binary file not shown.
Binary file modified src/Nca.Valdr.Nuget/lib/Nca.Valdr.dll
Binary file not shown.
10 changes: 9 additions & 1 deletion src/Nca.Valdr.Tests/DTOs/AddressDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
using System.Runtime.Serialization;

/// <summary>
/// Address data transfer object
/// Address data transfer object.
/// </summary>
[DataContract(Name = "address")]
[ValdrType(Name = "address")]
public class AddressDto
{
/// <summary>
/// Street name.
/// </summary>
[DataMember(Name = "street")]
[ValdrMember(Name = "street")]
[Display(ResourceType = typeof(Texts), Name = "Address_Street")]
public string Street { get; set; }

/// <summary>
/// City name
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions src/Nca.Valdr.Tests/DTOs/Texts.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions src/Nca.Valdr.Tests/DTOs/Texts.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,22 @@
<data name="Address_City" xml:space="preserve">
<value>City</value>
</data>
<data name="Address_ZipCode" xml:space="preserve">
<value>Zip code</value>
<data name="Address_Street" xml:space="preserve">
<value>Street</value>
</data>
<data name="Generic_MaximumLength" xml:space="preserve">
<value>{0} must be between {1} and {2} characters.</value>
<data name="Person_LastName" xml:space="preserve">
<value>Last name</value>
</data>
<data name="Person_FirstName" xml:space="preserve">
<value>First name</value>
</data>
<data name="Generic_RequiredField" xml:space="preserve">
<value>{0} is required.</value>
</data>
<data name="Person_FirstName" xml:space="preserve">
<value>First name</value>
<data name="Generic_MaximumLength" xml:space="preserve">
<value>{0} must be between {1} and {2} characters.</value>
</data>
<data name="Person_LastName" xml:space="preserve">
<value>Last name</value>
<data name="Address_ZipCode" xml:space="preserve">
<value>Zip code</value>
</data>
</root>
19 changes: 11 additions & 8 deletions src/Nca.Valdr.Tests/DTOs/Texts.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,22 @@
<data name="Address_City" xml:space="preserve">
<value>Ort</value>
</data>
<data name="Address_ZipCode" xml:space="preserve">
<value>PLZ</value>
<data name="Address_Street" xml:space="preserve">
<value>Strasse</value>
</data>
<data name="Generic_MaximumLength" xml:space="preserve">
<value>{0} muss zwischen {1} und {2} Zeichen sein.</value>
<data name="Person_LastName" xml:space="preserve">
<value>Nachname</value>
</data>
<data name="Person_FirstName" xml:space="preserve">
<value>Vorname</value>
</data>
<data name="Generic_RequiredField" xml:space="preserve">
<value>{0} ist obligatorisch.</value>
</data>
<data name="Person_FirstName" xml:space="preserve">
<value>Vorname</value>
<data name="Generic_MaximumLength" xml:space="preserve">
<value>{0} muss zwischen {1} und {2} Zeichen sein.</value>
</data>
<data name="Person_LastName" xml:space="preserve">
<value>Nachname</value>
<data name="Address_ZipCode" xml:space="preserve">
<value>PLZ</value>
</data>
</root>
23 changes: 21 additions & 2 deletions src/Nca.Valdr.Tests/ValidationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class ValidationTests
{
[Test]
public void PersonValidatorTest()
public void PersonValidatorInvalidTest()
{
// Arrange
var person = new PersonDto
Expand All @@ -28,8 +28,27 @@ public void PersonValidatorTest()
Assert.That(isValid, Is.False);
Assert.That(results[0].ErrorMessage, Is.EqualTo("First name is required."));
Assert.That(results[1].ErrorMessage, Is.EqualTo("Last name is required."));
Assert.That(results[2].ErrorMessage, Is.EqualTo("The field validTo is invalid."));
Assert.That(results[2].ErrorMessage, Is.EqualTo("validTo must be in the future"));
Assert.That(results[3].ErrorMessage, Is.EqualTo("Birthday must be in the past."));
}

[Test]
public void PersonValidatorValidTest()
{
// Arrange
var person = new PersonDto
{
FirstName = "Test",
LastName = "Test"
};
var context = new ValidationContext(person, serviceProvider: null, items: null);
var results = new List<ValidationResult>();

// Act
var isValid = Validator.TryValidateObject(person, context, results, validateAllProperties: true);

// Assert
Assert.That(isValid, Is.True);
}
}
}
8 changes: 8 additions & 0 deletions src/Nca.Valdr/FutureAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
[AttributeUsage(AttributeTargets.Property)]
public sealed class FutureAttribute : ValidationAttribute
{
/// <summary>
/// Default constructor.
/// </summary>
public FutureAttribute()
{
ErrorMessage = "{0} must be in the future";
}

/// <summary>
/// Determines whether the specified date is in the future.
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions src/Nca.Valdr/PastAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
[AttributeUsage(AttributeTargets.Property)]
public sealed class PastAttribute : ValidationAttribute
{
/// <summary>
/// Default constructor.
/// </summary>
public PastAttribute()
{
ErrorMessage = "{0} must be in the past";
}

/// <summary>
/// Determines whether the specified date is in the past.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Nca.Valdr/Properties/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.3.0")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion("1.1.3")]
[assembly: AssemblyVersion("1.1.4.0")]
[assembly: AssemblyFileVersion("1.1.4.0")]
[assembly: AssemblyInformationalVersion("1.1.4")]

0 comments on commit 4fbe395

Please sign in to comment.