Closed zhammer closed 5 years ago
@evanhammer do you have a reference to where you read about this pattern? functional programming invalidation standards or something?
This should be it for validators at the moment
Yes, I have examples, though they are not functional:
(in order of popularity)
https://github.com/chriso/validator.js
isConstraint
returns true. EBH: But this library only validates a single field against a single constraint. https://github.com/eivindfjeldstad/validate
I also looked into Folktale (a functional library of data structures) and its Validation object: https://folktale.origamitower.com/api/v2.3.0/en/folktale.validation.html
Success
or Failure
. Success has the original value. And Failure has an array of errors.
As per discussion with evan, invalidator can look something like:
(I guess this is where https://www.python.org/dev/peps/pep-0572/ would be nice)