Skip to content

Latest commit

 

History

History
18 lines (16 loc) · 651 Bytes

File metadata and controls

18 lines (16 loc) · 651 Bytes

FluentDefaults

A library for .NET that uses a fluent interface for setting default values, similar to how FluentValidation handles validations. It promotes cleaner code and better separation of concerns.

Example:

public class PersonDefaulter : AbstractDefaulter<Person>
{
    public PersonDefaulter()
    {
        DefaultFor(x => x.Id).Is(() => Guid.NewGuid());
        DefaultFor(x => x.IsVip).Is(false);
        DefaultFor(x => x.Discount).Is(20m).When(x => x.IsVip == true);
        DefaultFor(x => x.Discount).Is(10m).When(x => x.IsVip == false);
    }
}

More information here.