4 ms·
A concrete example would be the input (in JSON to pick a format) { "alpha": "3", "beta": "5" } Here, the fields `alpha` and `beta` are serialized as strin
by shepmaster 5y ago
A concrete example would be the input (in JSON to pick a format)
{ "alpha": "3", "beta": "5" }
Here, the fields `alpha` and `beta` are serialized as strings but should be treated as numbers. If the input were malformed:
{ "alpha": "dog", "beta": "cat" }
Then I'd like to get two validation errors for a single validation attempt. For example:
{ "alpha": ["must be a number"], "beta": ["must be a number"] }
> I believe the system presented is the concurrent solution.
It sounds like you are saying that I'd be able to get something isomorphic to the above, so that's good.
In addition to the above, I'd like to be able to say that once the values have been validated (a.k.a. parsed) as numbers, then `beta` must always be greater than `alpha`. This is a type of validation across fields that also depends on earlier validations (parsing, transformation, etc.) succeeding.
- belevy 5y agoSo you want something like `eitherContramap :: (b -> Either ErrMsg a) -> ValidationRule a -> ValidationRule b` we could define this as follows eitherContramap f rule = ValidationRule $ \b -> either failure (validate rule) (f b)