Skip to content

ljubomir/valdr-dotnet

 
 

Repository files navigation

valdr .NET Validation

Build status Coverage Status NuGet License

.NET plugin for valdr, an AngularJS model validator.

Offering

valdr .NET parses C# classes for DataAnnotation attributes and extracts their information into a JavaScript file, which includes the metadata to be used by valdr. This allows to apply the exact same validation rules on the server and on the AngularJS client.

Installation

To install the Nuget package, run the following command in the Package Manager Console:

PM> Install-Package Nca.Valdr

In Visual Studio, right-click your project and under Properties/Build Events add the following Post-build event:

$(SolutionDir)packages\Nca.Valdr.1.1.1\tools\Nca.Valdr.Console.exe -i:$(TargetDir)$(TargetFileName) -o:$(ProjectDir)app\app.valdr.js

Nca.Valdr.exe accepts the following parameters:

  • -i: input assembly filename (.dll)
  • -n: namespace filter (default: all)
  • -o: output JavaScript filename
  • -a: AngularJS application name (default: "app")
  • -c: Culture (optional, e.g. "en" or "en-US")

Dependencies

valdr .NET Validation is dependent on valdr in two ways:

Only C# classes decorated with a DataContract attribute will be used the generate the valdr metadata.

Mapping of .NET DataAnnotations attributes to valdr constraints

The .NET DataAnnotations attributes defines the mapping of .NET Validation to valdr constraints.

.NET DataAnnotations valdr Comment
Required required
Range min
Range max
StringLength size
digits unsupported
RegularExpression pattern
future unsupported
past unsupported
EmailAddress email
URL url

License

MIT © Netcetera AG

About

.NET plugin for valdr, an AngularJS model validator.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 65.4%
  • PowerShell 31.2%
  • JavaScript 3.4%