Skip to content

Tiny library for fluent guard and assert expressions to formalize preconditions of methods

License

Notifications You must be signed in to change notification settings

GreenParrotGmbH/FluentGuard

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FluentGuard

Tiny guard library for fluent precondition assertion. Current it is implemented for use with c#. Maybe a support for TypeScript and Java may be added.

Also in the near future a .net core / .net standard release will be aviable.

Feel free to fork !

Description

Offers a fluent way for making preconditions in a guard style. The idea is to have preconditions always in the same syntax and have less code.

Examples

NotNull Check

Preconditions
            .For(DomainObjectId, nameof(DomainObjectId))
            .NotNull();

Using lambdas instead of hardcoded name

Preconditions
            .For(()=> DomainObjectId)
            .NotNull();

Multiple checks

Preconditions
            .For(DomainObjectId, nameof(DomainObjectId))
            .NotNull()
            .MinLength(3);

Validaten models annotated with System.ComponentModel.DataAnnotations

Preconditions
            .For(()=>Model)
            .NotNull()
            .ValidateModel();

Next Steps

  • Add api-documentation
  • Make better names
  • Support .net standard
  • Implement TypeScript

#Nuget Package https://www.nuget.org/packages/FluentGuard

About

Tiny library for fluent guard and assert expressions to formalize preconditions of methods

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%