andrebaltieri / Flunt

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

Issue #6 Added Ability To Have Conditional Rules In Contract #21

Closed mstrYoda closed 5 years ago

mstrYoda commented 6 years ago

It resolves the issue : https://github.com/andrebaltieri/flunt/issues/6

Desired example use case in issue:

Contract.Required().IfNotNull(x.LastName, contract => contract.MinLength(3));

Implemented feature :

_dummy = new Dummy(); _dummy.stringProp = "abc";

var wrong = new Contract() .Requires() .IfNotNull(_dummy.stringProp, x => x.IsDigit(_dummy.stringProp, nameof(_dummy.stringProp), "Property should be digit if not null"));

mstrYoda commented 5 years ago

@andrebaltieri Hi Andre, do you have any free time to review this pr?