Do not go gentle into that impure night
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.