DynamicVNET 1.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DynamicVNET --version 1.4.0                
NuGet\Install-Package DynamicVNET -Version 1.4.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DynamicVNET" Version="1.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DynamicVNET --version 1.4.0                
#r "nuget: DynamicVNET, 1.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DynamicVNET as a Cake Addin
#addin nuget:?package=DynamicVNET&version=1.4.0

// Install DynamicVNET as a Cake Tool
#tool nuget:?package=DynamicVNET&version=1.4.0                

DynamicVNET - Overview

NuGet License: MIT

DynamicVNET is .NET Standard library that was created help to develop reuse dynamic validation. It helps to build some rules on POCO and own blackbox libs. It has rich conveniences and features as a <strong>Fluent API</strong> in runtime, wrapped over <strong>DataAnnotation</strong> attributes and supports a cross-platform environment.

Support

  • Branching & Nested Branching.
  • Nested Members.
  • Value Types & Single Primitive.
  • Reference Types (class).
  • Automatic ignoring of repeated validation.
  • Strongly Self Validator via Inheritance.

Where is using ?

  • POCO Validation.
  • Dynamic validation for private libraries (third party libraries 'dll').

Validation methods

  • Predicate (Custom)
  • StringLen
  • EmailAddress
  • Url (for GET)
  • Required
  • MaxLen
  • RegularExp
  • Range
  • Null (Only reference type)
  • NotNull (Only reference type)

Example

POCO Models.

public class Employee
{
   public string Name { get; set; }
   public Token TokenNumber { get; set; }
   public string Email { get; set; }
   
}
public class Token
{
   public string Number { get; set; }
}

Validation.

Employee emp = new Employee()
{
    Name = "Jhon", 
    TokenNumber = new Token() { Number = "2312412312341" }, 
    Email = "jhon.sim@gmail.com"
};

var validator = ValidatorFactory.Create<Employee>(builder => {
                    builder.Marker
                            .StringLen(x => x.Name, 4)
                            .EmailAddress(x => x.Email)
                            .Predicate(x => x.Email.Contains("@simple.com"))
                            .Required(x => x.TokenNumber.Number) //  nested member
                            .Required(x => x.TokenNumber.Number); // automatic ignored
                });        

bool result = validator.IsValid(emp);
// Detailed Result
IEnumerable<ValidationMarkerResult> results = validator.Validate(emp);
Branch Example
 var validator = ValidatorFactory.Create<Model>(builder => {
    builder.Marker
            .Required(x => x.Token.TokenNumber)
            .Branch(x => x.Name.Contains("resul"), x =>
             {
                 x.Required(y => y.Email)
                 .StringLen(y => y.Email, 2)
                     .Branch(n => n.Name.Length >= 4,n => {
                          n.MaxLen(s => s.Token.TokenNumber, length: 4);
                       });
            }).Branch(x => x.Email.Contains("aa"), x =>
              {
                  x.Required(y => y.Name)
                  .StringLen(y => y.Name, 5)
                  .StringLen(y => y.Token.TokenNumber, 9);
             });     
 });

Example Strongly Self Validator

public class EmployeeValidator : BaseValidator<Employee>
{
      protected override void Setup(ValidatorBuilder<Employee> builder)
      {
           builder.Marker
                     .For(x => x.Name)
                     .Required();

           builder.Marker
                   .Branch(x => x.Name.Contains("jhon"), x =>
                   {
                      x.MaxLen(m => m.TokenNumber.Number, 15);
                   })
                    .For(x => x.Email)
                    .Required()
                    .EmailAddress();

           builder.Marker
                   .Required(x => x.TokenNumber.Number);
      }
}
 
Employee emp = new Employee()
{
    Name = "selman:okkes", 
    TokenNumber = new Token() { Number = "adasd123123asd" }, 
    Email = "jhon.sim@jhona.com"
};
 
 
 var empValidator = new EmployeeValidator();
 bool result = empValidator.IsValid(emp);

Where can I get it?

Install DynamicVNET from the package manager console:

PM> Install-Package DynamicVNET -Version 1.4.0

DynamicVNET is Copyright © 2018 Rasul Huseynov.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DynamicVNET:

Package Downloads
DynamicVNET.Lib.AspNetCore

DynamicVNET.Lib extension for asp.net core. Extensible AOP (interceptor filter). Also allows to reuse marker validation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.1 80 10/31/2024
1.4.0 79 10/31/2024
1.4.0-beta 326 12/31/2020
1.3.1-alpha 332 7/30/2020
1.2.6 842 12/24/2018
1.2.5 662 12/20/2018
1.2.3 673 10/28/2018
1.2.2 742 9/23/2018
1.2.1 766 9/10/2018
1.2.0 793 9/7/2018
1.2.0-alpha 626 8/29/2018
1.1.1 745 8/23/2018
1.1.0 761 8/13/2018
1.0.3 775 8/7/2018