Open dotnetCarpenter opened 2 years ago
Since a value can have 3 distinct outcomes, I think that it would make the code more readable to encode that as a sum type.
Right a
A value is correct.Left MissingValue
Property is missing on the value.Left WrongValue
Value is wrong or property value on the value is wrong.@davidchambers How do you feel about requiring daggy in sanctuary-def? I haven't done anything with daggy yet and won't try if you don't feel it should be a dependency of sanctuary-def.
There is plenty of room for optimization but before I do any of that, I want to create a simple form validation example using the new $.validate
.
@davidchambers I really need you help to understand propPath
.
I might also need your help with sanctuary-benchmark. I looked at it before for https://github.com/dotnetCarpenter/express-mime-sniff but was not able to get anything working.
Signature
Example
Task before merge
$.validate
to confirm design. WIP sanctuary-def-validate$.validate
for readability while keeping an eye on performanceDescription
Takes a type, and any value. Returns
Right a
if the value is a member of the type;Left (Array ValidationError)
for each property that is invalid. The first index in aLeft
array is always named$$
, which refers to the entire value.Custom Type Example
Ref: https://github.com/sanctuary-js/sanctuary-def/issues/274