r-pankevicius / EnsureArg6

EnsureArg without nameof. Guard clause argument validation library for .NET based on Ensure.That.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EnsureArg6

EnsureArg without nameof.

Instead of writing:

public static void EnterClub(Person? person)
{
	EnsureArg.IsNotNull(person, nameof(person));
	EnsureArg.IsGte(person.Age, MinAge, $"{nameof(person)}.{nameof(person.Age)}");
	
	LetIn(person);
}

you can write:

public static void EnterClub(Person? person)
{
	EnsureArg6.IsNotNull(person);
	EnsureArg6.IsGte(person.Age, MinAge);
	
	LetIn(person);
}

and it will work the same. Example of failed validation example in both methods in case MinAge is 21 and person is { Name: "Andreas", Age: 17}:

System.ArgumentOutOfRangeException : Value '17' is not greater than or equal to limit '21'. (Parameter 'person.Age') Actual value was 17.

About

EnsureArg without nameof. Guard clause argument validation library for .NET based on Ensure.That.

License:MIT License


Languages

Language:C# 100.0%