Closed silvairsoares closed 3 years ago
You can use Linq, like this:
public class Program
{
class MyClass : Notifiable
{
public string Name { get; private set; }
public MyClass(string name)
{
Name = name;
AddNotifications(new Contract()
.Requires()
.IsNotNullOrEmpty(Name, nameof(Name), "Name cannot be null"));
}
}
public static void Main()
{
var myClassInstance = new MyClass(null);
List<string> myList = myClassInstance.Notifications.Select(n => $"{n.Property} : {n.Message}").ToList();
}
}`
to achieve the same result.
@natancmacedo Thanks for the suggestion, I opened a new pull #46, changing to use Linq.
Ill resolve this by removing <code>sealed</code> modifier from <code>Notification</code> class on next release! Then you
ll be able to extend it and create your own notification!
I
ll resolve this by removing <code>sealed</code> modifier from <code>Notification</code> class on next release! Then you
ll be able to extend it and create your own notification!
Thank you!
Creation of functionality to return validation failures in the following pattern:
[
"property 1": "failure"
"property 2": "failure"
...
]