andrebaltieri / Flunt

Validations and Notifications
https://github.com/andrebaltieri/flunt
MIT License
626 stars 162 forks source link

IsNullOrEmpty Validation Contract #30

Closed LuizFrra closed 5 years ago

LuizFrra commented 5 years ago

This validation is adding notification if its false and not adding else. Example : `

    public class Name : ValueObject
    {

    public string FirstName { get; private set; }

    public string LastName { get; private set; }

    public Name(string firstName, string lastName)
    {   
        AddNotifications(new Contract().Requires().IsNullOrEmpty(firstName, "Nome", "Nome Inválido"));

        FirstName = firstName;
        LastName = lastName;
    }
}`

Name name = new Name("", "Poe");

Console Output :

----- Test Execution Summary -----

PaymentContext.Tests.StudentTests.TestMethod1: Outcome: Passed

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0

if you changue the Method name to IsNotNullOrEmpty and do the inverse with IsNotNullOrEmpty fix everything.

andrebaltieri commented 5 years ago

THanks!! There`s a PR for that! Working on it!