Skip to content

Commit

Permalink
Merged task; pre-release docs fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszlenar committed Jun 23, 2020
2 parents c745802 + 181dd24 commit c6161b6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -14,7 +14,7 @@ Please replace the placeholders (like point lists or code snippets) with your ow

## Bug description

* Please provide the bug desciption in points.
* Please provide the bug description in points.
* What is the current behavior?
* What is affected by the bug?

Expand Down
20 changes: 13 additions & 7 deletions .github/README.md
Expand Up @@ -337,7 +337,7 @@ FluentValidation's `IsValid` is a property that wraps a simple check whether the
| IsValid | `NoErrors` | FluentValidation | `652.64` | `668.51` |
| IsValid | `NoErrors` | Validot | `266.63` | `78.82` |

* [IsValid benchmark](../tests/Validot.Benchmarks/Comparisons/ValidationBenchmark.cs) - objects are validated, but only to know if they are valid or not.
* [IsValid benchmark](../tests/Validot.Benchmarks/Comparisons/ValidationBenchmark.cs) - objects are validated, but only to check if they are valid or not.

In fact, combining these two methods in most cases could be quite beneficial. At first [IsValid](../docs/DOCUMENTATION.md#isvalid) quickly verifies the object and if it contains errors - only then [Validate](../docs/DOCUMENTATION.md#validate) is executed to report the details. Of course in some extreme cases (megabyte-size data? millions of items in the collection? dozens of nested levels with loops in reference graphs?) traversing through the object twice could neglect the profit, but for the regular web api input validation it will certainly serve its purpose:

Expand All @@ -361,7 +361,7 @@ if (!validator.IsValid(model))

Benchmarks environment: Validot 1.0.0, FluentValidation 8.6.2, .NET Core 3.1.4, i7-9750H (2.60GHz, 1 CPU, 12 logical and 6 physical cores), X64 RyuJIT, macOS Catalina.

### Validot handles nulls automatically
### Validot handles nulls on its own

In Validot, null is a special case [handled by the core engine](../docs/DOCUMENTATION.md#null-policy). You don't need to secure the validation logic from null as your predicate will never receive it.

Expand All @@ -372,14 +372,16 @@ Member(m => m.LastName, m => m
)
```

### Validot requires values by default
### Validot treats null as error by default

In opposition to FluentValidation, all values are marked as required by default. In the above example, if `LastName` member were null, the validation process would exit `LastName` scope immediately only with this single error message (content can be changed):
All values are marked as required by default. In the above example, if `LastName` member were null, the validation process would exit `LastName` scope immediately only with this single error message:

```
LastName: Required
```

The content of the message is, of course, [customizable](../docs/DOCUMENTATION.md#withmessage)).

If null should be allowed, place [Optional](../docs/DOCUMENTATION.md#optional) command at the beginning:

``` csharp
Expand Down Expand Up @@ -435,12 +437,16 @@ Validot is a dotnet class library targeting .NET Standard 2.0. There are no extr

Please check the [official Microsoft document](https://github.com/dotnet/standard/blob/master/docs/versions/netstandard2.0.md) that lists all the platforms that can use it on.

### Versioning

[Semantic versioning](https://semver.org/) is being used very strictly. Major version is updated only when there is a breaking change, no matter how small it might be (e.g. adding extra function to the public interface). On the other hand, huge pack of new features will bump the minor version only.

Before every major version update, at least one preview version is published.

### Reliability

Unit tests coverage hits 100% very close, it can be detaily verified on [codecov.io](https://codecov.io/gh/bartoszlenar/Validot/branch/master).

[Semantic versioning](https://semver.org/) is being used very strictly. Major version is updated only when there is a breaking change, no matter how small it might be (e.g. adding extra function to the public interface). On the other hand, huge pack of new features will bump the minor version only.

Before publishing, each release is tested on the [latest versions](https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources) of operating systems:

* macOS
Expand Down Expand Up @@ -471,4 +477,4 @@ Any contribution is more than welcome. If you'd like to help, please don't forge

### Licencing

Validot uses [MIT licence](../LICENCE). Long story short; you are more than welcome to use it anywhere you like, completely free of charge and without oppressive obligations.
Validot uses [MIT licence](../LICENSE). Long story short; you are more than welcome to use it anywhere you like, completely free of charge and without oppressive obligations.
4 changes: 2 additions & 2 deletions docs/CHANGELOG.md
Expand Up @@ -4,6 +4,6 @@ All notable changes to the [Validot project](https://github.com/bartoszlenar/Val
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0] - 2020-07-01
## [1.0.0] - 2020-06-23

First stable, public release. The reference point for all further changes.
First stable and public release. The reference point for all further changes.
3 changes: 1 addition & 2 deletions docs/CONTRIBUTING.md
Expand Up @@ -18,12 +18,11 @@ If you're reading this file, it means that you are - more or less - interested i

- Validot is not the ultimate solution to all validation scenarios and cases in the world. Let's keep it compact and simple, focused on a single problem.
- Validot should not have any other dependencies than .NET Standard 2.0.
- Validot - unless absolutely necessary and detaily discussed - should not sacrifice performance for extra features.
- Validot - unless absolutely necessary - should not sacrifice performance for extra features.
- Validot follows [semantic versioning](https://semver.org/) very strictly, no matter how annoying it could be.

## Code standards


- Be aware that the code needs to compile and pass the tests on all of the LTS versions of .NET, under all supported OSes.
- The CI system will let you know if your PR fails.
- Please ensure that your code is covered with unit and functional tests.
Expand Down
32 changes: 14 additions & 18 deletions docs/DOCUMENTATION.md
Expand Up @@ -1733,12 +1733,10 @@ var publisher = new PublisherModel()
CompanyId = ""
};

publisherValidator.Validate(publisher).ToString().ShouldResultToStringHaveLines(
ToStringContentType.Messages,
"Info: Name must consist of letters only!",
"Info: Name must not contain whitespace!",
"Info: Company Id must not be empty!"
);
publisherValidator.Validate(publisher).ToString();
// Info: Name must consist of letters only!
// Info: Name must not contain whitespace!
// Info: Company Id must not be empty!
```

_[Error messages](#message) from two scopes (members `Name` and `CompanyId`) are both placed under `Info` path._
Expand Down Expand Up @@ -1888,12 +1886,10 @@ Specification<int> specification = s => s

var validator = Validator.Factory.Create(specification);

validator.Validate(0).ToString().ShouldResultToStringHaveLines(
ToStringContentType.Messages,
"Year 0 is invalid",
"Year 0 didn't exist",
"Please change to 1 B.C. or 1 A.D."
);
validator.Validate(0).ToString();
// Year 0 is invalid
// Year 0 didn't exist
// Please change to 1 B.C. or 1 A.D.
```

- `WithExtraMessage` acts very similar to [WithMessage](#withmessage), with one important difference; in case of error it appends message to the [error output](#error-output) of the related scope, instead of overwriting it (as [WithMessage](#withmessage) would do).
Expand Down Expand Up @@ -2301,7 +2297,7 @@ var book = new BookModel() { Title = null };

var result = validator.Validate(book);

result.Codes.Should().ContainSingle("MISSING_TITLE");
result.Codes; // [ "MISSING_TITLE" ]
result.ToString();
// MISSING_TITLE
Expand Down Expand Up @@ -2351,7 +2347,7 @@ var book = new BookModel() { Title = null };

var result = validator.Validate(book);

result.Codes.Should().ContainSingle("TITLE_EXISTS");
result.Codes; // [ "TITLE_EXISTS" ]
result.ToString();
// TITLE_EXISTS
Expand Down Expand Up @@ -3263,7 +3259,8 @@ var result = validator.Validate(publisher);
result.MessageMap["Name"];
// [ "The field is empty", "Error in Name field", "The field is too short", "Error in Name field" ]
result.MessageMap[""].Should().ContainSingle("All members must be present");
result.MessageMap[""];
// [ "All members must be present" ]
```

- If the [path](#path) is not present in `MessagesMap.Keys` collection, it means no [code](#code) has been saved for it.
Expand Down Expand Up @@ -4101,9 +4098,8 @@ Specification<string> specification = s => s

var validator = Validator.Factory.Create(specification);

validator.Validate("").ToString().ShouldResultToStringHaveLines(
ToStringContentType.Messages,
"Must contain @ character");
validator.Validate("").ToString();
// Must contain @ character
```

_In the above code, [WithMessage](#withmessage) sets `"Must contain @ character"` message key for [Rule](#rule). However, there is no such message key in the standard, default `English` translation, so [ToString](#tostring) prints the original message key._
Expand Down

0 comments on commit c6161b6

Please sign in to comment.