Reputation: 4254
export const getValueFromPsetProperty = (pset: string, property: string) => R.pipe(
R.prop('pSets'),
R.find(R.propEq('name', pset)),
R.propOr([], 'properties'),
R.find(R.propEq('name', property)),
R.propOr(null, 'value'),
R.ifElse(isValueValid, null,R.identity),
);
The last pipe does not work. What I want to do is to pass the value if isValueValid
is true. How should I do this?
Upvotes: 0
Views: 1320
Reputation: 18941
It doesn't look like you're using R.ifElse
correctly. All first three arguments should be functions:
So from what you're describing, you want to return the value unchanged if isValueValid
returns true. In this case your R.ifElse
should be:
R.ifElse(isValueValid, R.identity, someOtherFunction)
You may want to consider R.unless
which will run a function only if a predicate is false. If value is valid, then the R.unless
returns it unchanged.
R.unless(isValueValid, someFunctionIfValueIsNotValid);
Upvotes: 4