-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [WIP] Beginner-Friendly `Validated` docs This commit is the first approach to address #1678, developing the form-validation example. * Beginner-friendly example of validated. This commit contains a simple form-validation example and a couple of approaches making use of `Validated`. It aims to solve #1678 * Use of `tut` for code checking - The code examples for form validation are now using `tut` with its respective output in the generated .html. - Fixes some structural issues (`Either` return type in the `Validated` example, use of `mapN` instead of `|@|`). - Adds a deprecation notice about cartesian builder and changes this for using `.mapN`. * Fixes failing `tut` snippet. - The `Validated` approach with the for-comprehension has been splitted in two: the instructions that compile and the for-comprehension that doesn't compile. For the first ones, I've used `tut:silent` and for the second one I've used `tut:book:fail`. With this, all the code of this proposal is checked by tut correctly. - Adds an import for Either to bring .flatMap in Scala versions prior to 2.12.x. * Fixes - Fixes indentation in all the snippets (two spaces). - Added a new section ("short detour") in where I explain the `Semigroup` role in the accumulation, with a little portion of `Validated` code. - Adds "Back and forth" section explaining how to convert between `Validated` and `Either`. I can't figure it out how to convert from `Either` to `Validated` 'failing slowly'. * Revamped some parts of this docs - Added `final` modifier to `RegistrationData` case class. - Changed if-else in `Either` example to `Either.cond`. - Reused `Either` example validations in `Validated` (non-compiling) approach with `.toValidated`. - Deleted redundant imports for tut. - Changed `Validated` of a `NonEmptyList` for `ValidatedNel` type alias. - Deleted 'disclaimer' about converting from `Validated` to `Either`, losing the fail-slow functionality. - Added `Semigroup` example based on the Peter's one but in the context of the example provided here. - Fixed some typos and grammar errors. - Pointed out to the cats `Semigroup` documentation instead of Wikipedia.
- Loading branch information
1 parent
bafb427
commit dc8637d
Showing
1 changed file
with
323 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters