

Do not go gentle into that impure night
source link: https://impure.fun/fun/2021/01/11/fable-validation-blocks/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

༶・・ ᗰદ૨૨y ᘓમ૨ıડτന੨ડ ・・༶ F# /\ F# /|>\ F# /\ / |> \ /\ />=\ /"%A"\ />>\ /"%d"\ /()->`a\ /"%i"\ ~~~~~~~~~ [] ~~~ ``[||]`` ~~~ [] ~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~[||]~~~~~~~~~~~~~~~~~~~
Functional code for humans
Do not go gentle into that impure night
11 Jan 2021Don't miss the live demo link at the bottom of the article, it's juicy stuff 👇
If there’s anything worse than writing javascript, it’s having to read the javascript that you write. Thanks to Fable, you can write javascript that you don’t have to read, indeed you don’t even have to write it.
Similarly, FSharp.ValidationBlocks allows you to validate things without writing any validation code, only rules. Yes, you can try to do validation without it, but like going to the toilet without toilet paper, it’s possible but it can be messy.
Thanks, I’ll take both ✌
You’d be forgiven for trying to combine them like Voltron as web apps often display forms that require validation. Unfortunately the reflection that makes FSharp.ValidationBlocks
magical also made it incompatible with Fable.
No happy ending? 💔
But hold on for a second - in a plot twist that everybody saw coming - these things can be used together now, and all it took was adding .Fable
to the namespace FSharp.ValidationBlocks
making a new namespace FSharp.ValidationBlocks.Fable
. How did I not think of this before!
Should I try it?
I don’t know, let’s see:
- Does doing proper ROP validation without writing a single Result<string, string list> sound good to you?
- Is having all your guaranteed-to-be-valid types defined with as little as 3 lines of code music to your ears?
- Does not having to think where validation rules go or remembering to check them appeal to you?
I’m going to stop now because I ran out of sound metaphors, but the point is, yes, you should definitely try it, and thanks to Fable now there’s a live demo 🎁! So meta…
Disclaimer
Don’t get triggered by my throwing shade at javascript, it’s just for comedic purposes, I have a lot of respect for that language that got many things right from the beginning.
Recommend
-
74
Whenever we mention Context and Dependency Injection, we automatically think about Java EE (Since CDI 1.0 focused strongly on Java EE). But, as you probably know, you don't necessarily need a Java EE (EE4J) application server to enjoy CDI m...
-
9
Late night turns into early morning on a support call I once worked at a place which used customer service as their major selling point. They were far more expensive than the other companies who also nominally provided the same s...
-
5
Reborn — impure.fun · Mostly for profit ༶・・ ᗰદ૨૨y ᘓમ૨ıડτന੨ડ ・・༶ F# /\ F# /|>\ F# /\ / |> \ /\ />=\ /"%A"\...
-
18
May 13, 2021 ...
-
4
A not so gentle intro to web3 Friday, 31 December 2021 ∙ 8 minute read Almost everything web3-related is a grift based on getting people to buy crypto. Although the distributed part of blockchain technology is so...
-
6
Pure and Impure Functions in JavaScript: A Complete GuidePure functions and impure functions are two common terms used in JavaScript. On the surface level, both functions look identical.However, if we loo...
-
11
“Not a day without a line” — The gentle discipline of drawing every dayFrom ancient Greek painter Apelle to contemporary calligrapher Fabienne Verdier, the wisdom of drawing a line every day...
-
10
What is the difference between pure and impure pipes, and how can we use each in Angular?Angular provides us with an organized way to build frontend web apps. One entity that it has is pipes.Pipes let us render items in component tem...
-
4
-
2
Mobile phones have become an integral part of our lives. They have changed the way we communicate, work, and even socialize. However, their constant use has also led to some negative consequences, such as increased stress and anxiety. Google recog...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK