https://github.com/jacraig/valkyrie
Valkyrie is a validation library for .Net.
https://github.com/jacraig/valkyrie
validation-library
Last synced: 11 months ago
JSON representation
Valkyrie is a validation library for .Net.
- Host: GitHub
- URL: https://github.com/jacraig/valkyrie
- Owner: JaCraig
- License: apache-2.0
- Created: 2017-01-25T21:02:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-10-30T00:05:35.000Z (over 1 year ago)
- Last Synced: 2024-10-30T02:44:37.417Z (over 1 year ago)
- Topics: validation-library
- Language: C#
- Homepage: https://jacraig.github.io/Valkyrie/
- Size: 17.3 MB
- Stars: 2
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Valkyrie
[](https://github.com/JaCraig/Valkyrie/actions/workflows/dotnet-publish.yml)
Valkyrie is a simple set of data annotations and extension methods to help with validating your objects in .NET.
## Basic Usage
For the most part, Valkyrie consists of DataAnnotations. To use Valkyrie, simply add the annotations to your properties as shown below:
```csharp
public class MyClass
{
[Cascade]
public MyOtherClass ItemA { get; set; }
[Between("1/1/1900", "1/1/2100")]
public DateTime ItemB { get; set; }
[Contains("A")]
public List ItemC { get; set; }
}
```
The `System.ComponentModel.DataAnnotations.Validator` class will automatically pick up these annotations when validating your object. Additionally, there are a couple of extension methods added to simplify object validation:
```csharp
var results = new List();
bool didItWork = MyObject.TryValidate(results);
```
And:
```csharp
MyObject.Validate();
```
The `TryValidate` method returns a list of validation results, while the `Validate` method throws a `ValidationException` if there are any issues with validating your object.
## Installation
The library is available on NuGet with the package name "Valkyrie." To install it, run the following command in the Package Manager Console:
```
Install-Package Valkyrie
```
## Build Process
To build the library, make sure you have the following minimum requirements:
- Visual Studio 2022
Simply clone the project and load the solution in Visual Studio. You should be able to build it without much effort.
## Contributing
We welcome contributions to Valkyrie. If you find any issues or have suggestions for improvements, please open an issue or submit a pull request. We appreciate your support!