HxValidator 2.0.0

.Net developers, now manage easyly your models validations by customizing different properties rules. This specially for object oriented programming.

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

HxValidator Documentation


HxValidator is netstandard based library that allows C# and VB developpers managing
models validations accross all .Net Frameworks. It is simple to use, see an
example describing how to achieve this.


Example


This library contains a class named HxObject which your projet model have to
heritate and access to this base class methodes, properties, etc.

Github C# and VB sources projects examples here.

  1. Create model
namespace HxExample
{
   public class HxClass : HxValidator.HxObject<HxClass>
   {
		private string _name;
      private int _age;

       public HxClass()
           : base()
       {

       }
   }
}
  1. Define your properties
	...
	public string Name
	{
		get { return _name; }
		set
		{
			SetProperty(ref _name, value);
		}
	}
	public int Age
	{
		get { return _age; }
		set
		{
			SetProperty(ref _age, value);
		}
	}
	...
  1. Define model rules
	...
	// Constructor
	public HxClass()
		: base()
	{
		// Name value can't be empty
       Rules.Add(new DelegateRule<HxClass>(
           "Name",
           "Name value can't be empty!!!",
           x => !string.IsNullOrEmpty(x.Name)));

       // Age value have to be greater than 12
       Rules.Add(new DelegateRule<HxClass>(
           "Age",
           "Age value have to be greater than 12!!!",
           x => x.Age > 12));
	}
	...
  1. Test if model is valid
	...
	HxClass hx = new HxClass();
	bool result = hx.HasErrors;
	...
  1. Get errors
	...
	// Get whole model errors
	hx.GetErrors();

	// Get single property errors
	hx.GetErrors("Name");
	...

Thanks for choosing HxValidator

HxValidator Documentation


HxValidator is netstandard based library that allows C# and VB developpers managing
models validations accross all .Net Frameworks. It is simple to use, see an
example describing how to achieve this.


Example


This library contains a class named HxObject which your projet model have to
heritate and access to this base class methodes, properties, etc.

Github C# and VB sources projects examples here.

  1. Create model
namespace HxExample
{
   public class HxClass : HxValidator.HxObject<HxClass>
   {
		private string _name;
      private int _age;

       public HxClass()
           : base()
       {

       }
   }
}
  1. Define your properties
	...
	public string Name
	{
		get { return _name; }
		set
		{
			SetProperty(ref _name, value);
		}
	}
	public int Age
	{
		get { return _age; }
		set
		{
			SetProperty(ref _age, value);
		}
	}
	...
  1. Define model rules
	...
	// Constructor
	public HxClass()
		: base()
	{
		// Name value can't be empty
       Rules.Add(new DelegateRule<HxClass>(
           "Name",
           "Name value can't be empty!!!",
           x => !string.IsNullOrEmpty(x.Name)));

       // Age value have to be greater than 12
       Rules.Add(new DelegateRule<HxClass>(
           "Age",
           "Age value have to be greater than 12!!!",
           x => x.Age > 12));
	}
	...
  1. Test if model is valid
	...
	HxClass hx = new HxClass();
	bool result = hx.HasErrors;
	...
  1. Get errors
	...
	// Get whole model errors
	hx.GetErrors();

	// Get single property errors
	hx.GetErrors("Name");
	...

Thanks for choosing HxValidator

Release Notes

HxValidator now can be used in VB.Net project

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.0.0 136 12/13/2018
1.5.0 112 12/11/2018