You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multiple validation are somewhat verbose to write for custom types:
constEfficiency=withValidate(NumberFromString,(u,c)=>either.chain(NumberFromString.validate(u,c),n=>{if(n<=0){returnt.failure(u,c,`${n}% is not effcient enough and will not heat water.`)}elseif(n>=100){returnt.failure(u,c,`${n}% efficiency is against the laws of physics`)}returnt.success(n)}))
Desired Behavior
constEfficiency=withValidate(NumberFromString,(u,c)=>pipe(NumberFromString.validate(u,c),validate(n=>n>0||`${n}% is not effcient enough and will not heat water.`)(u,c),validate(n=>n<100||`${n}% efficiency is against the laws of physics`)(u,c)))
Suggested Solution
My solution with pipe and this implementation of validate
It does not work though as pipe is complaining about incompatible args.
It would also be nice to get rid of the NumberFromString.validate call, and make this somehow implicit.
Being new to FP I am lost here.
Who does this impact? Who is this for?
It would benefit advanced users I guess.
The text was updated successfully, but these errors were encountered:
🚀 Feature request
Current Behavior
Multiple validation are somewhat verbose to write for custom types:
Desired Behavior
Suggested Solution
My solution with
pipe
and this implementation ofvalidate
It does not work though as
pipe
is complaining about incompatible args.It would also be nice to get rid of the
NumberFromString.validate
call, and make this somehow implicit.Being new to FP I am lost here.
Who does this impact? Who is this for?
It would benefit advanced users I guess.
The text was updated successfully, but these errors were encountered: