https://github.com/jjosh102/obaki.datachecker
Obaki.DataChecker is a flexible library that simplifies data validation for JSON and XML inputs. Use customized rules to verify data accuracy and reliability with ease.
https://github.com/jjosh102/obaki.datachecker
csharp csharp-library show
Last synced: about 1 year ago
JSON representation
Obaki.DataChecker is a flexible library that simplifies data validation for JSON and XML inputs. Use customized rules to verify data accuracy and reliability with ease.
- Host: GitHub
- URL: https://github.com/jjosh102/obaki.datachecker
- Owner: jjosh102
- License: mit
- Created: 2023-04-07T10:00:59.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-20T09:49:52.000Z (over 2 years ago)
- Last Synced: 2024-12-23T13:47:50.499Z (over 1 year ago)
- Topics: csharp, csharp-library, show
- Language: C#
- Homepage:
- Size: 58.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Obaki.DataChecker
[](https://www.nuget.org/packages/Obaki.DataChecker)
[](https://www.nuget.org/packages/Obaki.DataChecker)
Obaki.DataChecker is a library that provides flexible validation of JSON and XML inputs through customizable rules, while allowing for custom validations using [FluentValidation](https://github.com/FluentValidation/FluentValidation).
## Installing
To install the package add the following line inside your csproj file with the latest version.
```
```
An alternative is to install via the .NET CLI with the following command:
```
dotnet add package Obaki.DataChecker
```
For more information you can check the [nuget package](https://www.nuget.org/packages/Obaki.LocalStorageCache).
## Setup
Register the needed services in your Program.cs file as **Scoped**
```c#
public void ConfigureServices(IServiceCollection services)
{
services.AddDataCheckerAsScoped();
}
```
Or as **Singleton**
```c#
public void ConfigureServices(IServiceCollection services)
{
services.AddDataCheckerAsSingleton();
}
```
## Usage
**Asynchronous(Non-Blocking)**
```c#
using FluentValidation.Results;
using FluentValidation;
using Obaki.DataChecker;
public class TestAsync {
private readonly IXmlDataChecker _xmlDataChecker;
public TestAsync(IXmlDataChecker xmlDataChecker)
{
_xmlDataChecker = xmlDataChecker;
}
public async Task ValidateTestObject(string xmlInput)
{
return await _xmlDataChecker.ValidateXmlDataFromStringAsync(xmlInput);
}
}
```
**Synchronous(Blocking)**
```c#
using FluentValidation.Results;
using FluentValidation;
using Obaki.DataChecker;
public class TestSync {
private readonly IXmlDataChecker _xmlDataChecker;
public TestAsync(IXmlDataChecker xmlDataChecker)
{
_xmlDataChecker = xmlDataChecker;
}
public ValidationResult ValidateTestObject(string xmlInput)
{
return _xmlDataChecker.ValidateXmlDataFromString(xmlInput);
}
}
```