BlazingSolutions / TimeKeeper

A project for learning Blazor
9 stars 0 forks source link

Implemented validation for adding a new time entry #64

Closed jonhilt closed 3 years ago

jonhilt commented 3 years ago

This validation works on both the client and the API, using the exact same validator.

This has the advantage that initial validation is nice and snappy because it's performed on the client, but even if someone bypassed that (somehow by mistake, or in a deliberate attempt to bypass the validation) the API will apply the same rules.

I implemented an action filter in the API so there's no need to check ModelState in every controller action, the filter will do this automatically for all requests.

DotNetDublin commented 3 years ago

Thanks @jonhilt.

Look forward to reviewing this evening. Might even drop a refactoring video! 😊

DotNetDublin commented 3 years ago

Hi @jonhilt

Works great and I confirmed that the validation was being applied both from the form and the api.

Unrelated to the fluent validation I updated the Min, Max and Step attributes of the Hours field in order to allow decimals to be entered.

form-validation

api-validation