DynamicVNET 1.3.1-alpha

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 Fluent API in runtime, wrapped over DataAnnotation attributes and supports a cross-platform environment.

This is a prerelease version of DynamicVNET.
Install-Package DynamicVNET -Version 1.3.1-alpha
dotnet add package DynamicVNET --version 1.3.1-alpha
<PackageReference Include="DynamicVNET" Version="1.3.1-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DynamicVNET --version 1.3.1-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

DynamicVNET - Overview

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 [synonim logical tree].
  • 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
  • PhoneNumber
  • 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 = new Validator<Employee>(builder => {
                builder.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.IsValidate(emp);

Detailed Result.


IEnumerable<ValidationMarkerResult> results = validator.Validate(emp);
// Only invalid results or all results.
IEnumerable<ValidationMarkerResult> results = validator.ValidateAll(emp);
Branch Example
 var validator = new Validator<Model>(builder => {
 
 builder.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 : Validator<Employee>
{
        public EmployeeValidator()
        {
            builder.SetMember(x => x.Name)
                .Required()
            .Branch(x => x.Name.Contains("jhon"), x =>
            {
                x.MaxLen(m => m.TokenNumber.Number, 15);
            })
            .SetMember(x => x.Email)
                .Required()
                .EmailAddress()
            .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.IsValidate(emp);

Where can I get it?

Install DynamicVNET from the package manager console:

PM> Install-Package DynamicVNET -Version 1.3.1-alpha

License & Copyright

DynamicVNET is Copyright © 2018 Rasul Huseynov and lincensed under the MIT license.

DynamicVNET - Overview

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 [synonim logical tree].
  • 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
  • PhoneNumber
  • 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 = new Validator<Employee>(builder => {
                builder.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.IsValidate(emp);

Detailed Result.


IEnumerable<ValidationMarkerResult> results = validator.Validate(emp);
// Only invalid results or all results.
IEnumerable<ValidationMarkerResult> results = validator.ValidateAll(emp);
Branch Example
 var validator = new Validator<Model>(builder => {
 
 builder.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 : Validator<Employee>
{
        public EmployeeValidator()
        {
            builder.SetMember(x => x.Name)
                .Required()
            .Branch(x => x.Name.Contains("jhon"), x =>
            {
                x.MaxLen(m => m.TokenNumber.Number, 15);
            })
            .SetMember(x => x.Email)
                .Required()
                .EmailAddress()
            .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.IsValidate(emp);

Where can I get it?

Install DynamicVNET from the package manager console:

PM> Install-Package DynamicVNET -Version 1.3.1-alpha

License & Copyright

DynamicVNET is Copyright © 2018 Rasul Huseynov and lincensed under the MIT license.

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 History

Version Downloads Last updated
1.3.1-alpha 93 7/30/2020
1.2.6 254 12/24/2018
1.2.5 206 12/20/2018
1.2.3 211 10/28/2018
1.2.2 237 9/23/2018
1.2.1 232 9/10/2018
1.2.0 240 9/7/2018
1.2.0-alpha 223 8/29/2018
1.1.1 236 8/23/2018
1.1.0 244 8/13/2018
1.0.3 273 8/7/2018