Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Latest commit

 

History

History
22 lines (19 loc) · 1.12 KB

README.md

File metadata and controls

22 lines (19 loc) · 1.12 KB

The RedHttp project is no longer maintained. See Carter for a similar low-ceremony experience.

Red.Validation

Extensions for FormValidator for creating Red middleware

GitHub Nuget Nuget Dependent repos (via libraries.io)

Example

Create middleware function

public static readonly Func<Request, Response, Task<HandlerType>> ValidateLoginForm = ValidatorBuilder.New()
    .RequiresString("username", s => WithLength(s, MinUsernameLength, MaxUsernameLength))
    .RequiresString("password", s => WithLength(s, MinPasswordLength, MaxPasswordLength))
    .BuildRedFormMiddleware();

And then use it

server.Get("/login", ValidateLoginForm, PerformLogin);