Comments (4)
Thanks, I'll take a look. I came across Chessie the other day while researching something else funnily enough.
With regard to Warn - any thoughts on how to add that while keeping the syntax super clean? Initially that's why I avoided it (well that and that I didn't need it allowed me to duck it!!).
ROP - yes, but I came across that by way of Kit Eason's book rather than (the excellent and well thumbed by me over the last six months) Fun and Profit.
Thanks for the input :)
from accidentalfish.fsharp.validation.
Actually... just had a nice idea about Warn. Will take a look later today.
from accidentalfish.fsharp.validation.
Something like this:
validate (fun r -> r.title) [
isNotEmpty
hasMaxLengthOf 128
warn [
hasMinLengthOf 32
]
]
from accidentalfish.fsharp.validation.
Yeah, that looks ok for associating additional info along with the validation.
I'm not sure how it fits in the context of validation though. Perhaps the warn could indicate interdependent fields? If Field1 is valid then Warn other Fields is also flip from optional to required (e.g. Address must have a Postal code or State). I often nest validation in this case though as it means Field1 doesn't have dependencies on other fields.
In your example, above, I can imagine Warn [ passwordWeak ] could be a suitable use.
The warn concept actually fits with Chessie even more closly.
Chessie defines the Result as:
type Result<'TSuccess, 'TMessage> =
| Ok of 'TSuccess * 'TMessage list
| Bad of 'TMessage list
OK is OK with an empty list, Warn is OK with a list of messages and Bad represents the failure.
There are a bunch of active patterns as well as apply, lift and map type functions in Chessie so that you can compose each of the functions together using |>. At the bottom of the chained functions, you effectively get a list of errors.
I used it heavily in a DSL that I made to create a tree of functions that extract the data from the HTML. The DSL -> Result<FunctionRoot, DSLErrors>. when I run FunctionRoot(HtmlDom) -> Result<Json, ParseErrors>.
The error list that came out was actually a complete list of errors for the whole DSL as well as each of the branches that run when the DSL "program" ran. That way, I didn't have to fix, test, fix etc.
I didn't really have a use for Warn in that case but I felt that Warn is domain specific and the above Chessie Result type for OK having the message list was probably the best fit for Warn (even though I didn't use it).
from accidentalfish.fsharp.validation.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from accidentalfish.fsharp.validation.