Advent of Code 2022 - Day 4

Puzzle: Camp Cleanup

December 4, 2022

Advent of Code 2022 - Day 3

Puzzle: Rucksack Reorganization

December 3, 2022

Advent of Code 2022 - Day 2

Puzzle: Rock Paper Scissors

December 2, 2022

Advent of Code 2022 - Day 1

Puzzle: Calorie Counting

December 1, 2022

Fluent Validation - Tests

In the previous posts, we’ve learned how to create validators. Set the required rules and build custom validators. To finish learning using the fluent validation library, we’ll write some tests to be sure that we defined rules properly. Unit test extensions The validation library consists of two extension methods for validators which allow checking if a validator has or not any error for the chosen property. There are a few methods to use:...

March 31, 2020

Fluent Validation - Complex Usage

In the previous posts, I’ve presented some basic info and possible configuration. Now, it’s time to show more complex examples. Custom Validator Sometimes build-in validator may not be enough. Then, you need to create it on your own. To have custom validator you define a class that inherits from PropertyValidator. We can pass the validation message to the base class. Moreover, our validation should be written inside IsValid the method....

August 1, 2019

Fluent Validation - Configuration

Previously I’ve presented some introduction to Fluent Validation. In this post, I’m going to cover some configuration possibilities. Such as arranging validation processing to receive different results. Cascade mode At first, let’s manage validation execution. Cascade mode allows to setup how chained validators are executed. For example, there is a rule with two validators NotEmpty and GreaterThan: RuleFor(e => e.Number).NotEmpty().GreaterThan(10); When using that rule, it checks both of the validators no matter if the first validator fails or not....

May 25, 2019

Fluent Validation - Introduction

Fluent Validation is a .NET library used to define validation rules for an object’s data. In the following post, I show the basic usage. At first, you need to add FluentValidation.dll to your project. For .NET Core use CLI command: dotnet add package FluentValidation However, if you are using NuGet run: Install-Package FluentValidation Validator To illustrate a basic concept, I use example class that will help to introduce different rules....

May 21, 2019