andrebaltieri / Flunt

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

HasMaxLen conflict with "" #35

Closed fernandopassaia closed 5 years ago

fernandopassaia commented 5 years ago

What I want: User can add OR not a value, but if ADD, cannot be higher than some length... so for example:

.HasMaxLen(ZipCode, 10, "ZipCode", "ZipCode can't be longer than 10.")

The issue: If user don't add Anything and Field is Empty (ZipCode = "") - Flunt generates a Notification anyway. I'm sending always " " (with a space in middle) to avoid the exception...

fernandopassaia commented 5 years ago

My mistake, i found the method HasMaxLengthIfNotNullOrEmpty... thanks