Skip to content

mersocarlin/ddd-validation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

ddd-validation

DDD Library for validate your entities according Vaughn Vernon using C# / ASP.NET.

Install via nuget package

Install-Package DDDValidation

Setup your class

using DDDValidation.Validation;

namespace ExampleOfUse
{
	public class DDDValidationClass
	{
	    public DDDValidationClass()
	    {

	    }

	    public string EqualsProperty { get; set; }
	    public string LengthProperty { get; set; }
	    public string NullProperty { get; set; }
	    public string EmailProperty { get; set; }

	    public void Validate()
	    {
	        AssertionConcern.AssertArgumentEquals(this.EqualsProperty, "ddd-validation", "The property value for EqualsProperty must be equals to 'ddd-validation'");
	        AssertionConcern.AssertArgumentLength(this.LengthProperty, 30, "The property value for LengthProperty has a maxlength of 30");
	        AssertionConcern.AssertArgumentNotNull(this.NullProperty, "The value for NullProperty must be a not null value");
	        EmailAssertionConcern.AssertEmailFormat(this.EmailProperty, "The property value for EmailProperty must be a valid email address");
	    }
	}
}

Example of usage

public void SaveInfo(DDDValidationClass validationClass)
{
    try
    {
        validationClass.Validate();
        //continue implementation
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
        throw ex;
    }
}

About

DDD Library for validate your entities according Vaughn Vernon using C# / ASP.NET

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages