Skip to content

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.

License

Notifications You must be signed in to change notification settings

jjosh102/Obaki.DataChecker

Repository files navigation

Obaki.DataChecker

NuGet NuGet Downloads

Obaki.DataChecker is a library that provides flexible validation of JSON and XML inputs through customizable rules, while allowing for custom validations using FluentValidation.

Installing

To install the package add the following line inside your csproj file with the latest version.

<PackageReference Include="Obaki.DataChecker" Version="x.x.x" />

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.

Setup

Register the needed services in your Program.cs file as Scoped

public void ConfigureServices(IServiceCollection services)
{
    services.AddDataCheckerAsScoped();
}

Or as Singleton

public void ConfigureServices(IServiceCollection services)
{
    services.AddDataCheckerAsSingleton();
}

Usage

Asynchronous(Non-Blocking)

using FluentValidation.Results;
using FluentValidation;
using Obaki.DataChecker;


public class TestAsync {
    private readonly IXmlDataChecker<TestObject> _xmlDataChecker;

    public TestAsync(IXmlDataChecker<TestObject> xmlDataChecker) 
    {
          _xmlDataChecker = xmlDataChecker;
    }

   public async Task<ValidationResult> ValidateTestObject(string xmlInput)
   {

          return await _xmlDataChecker.ValidateXmlDataFromStringAsync(xmlInput);
   }
}

Synchronous(Blocking)

using FluentValidation.Results;
using FluentValidation;
using Obaki.DataChecker;


public class TestSync {
   private readonly IXmlDataChecker<TestObject> _xmlDataChecker;

    public TestAsync(IXmlDataChecker<TestObject> xmlDataChecker) 
    {
          _xmlDataChecker = xmlDataChecker;
    }

   public ValidationResult ValidateTestObject(string xmlInput)
   {

          return  _xmlDataChecker.ValidateXmlDataFromString(xmlInput);
   }
}

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages