These are chat archives for ramda/ramda

22nd
Feb 2018
David
@DavidBernal
Feb 22 2018 19:17
hi, I'm just beginning in FP, and I'm trying to validate if all props in object are empty. For example:
const myObj = {one: '', two: ''}; // must return true
const myObj2 = {one: 'asd', two: '}; // must return false
I tried with const anyIsNotEmpty = compose(not, isEmpty, values);
but I think is an error
Mike Lambert
@lax4mike
Feb 22 2018 19:18
you can use R.any
or R.all
does this do what you want?
const allAreEmpty = R.compose(
  R.all(R.isEmpty), 
  R.values
);
David
@DavidBernal
Feb 22 2018 19:22
yes, thank you
Mike Lambert
@lax4mike
Feb 22 2018 19:23
:thumbsup:
David
@DavidBernal
Feb 22 2018 19:24
do I need pass isEmptyto all when I create the composed function? Can't I chain like the other functions?
Bijoy Thomas
@bijoythomas
Feb 22 2018 19:26
@DavidBernal isEmpty by itself might not be a complete check depending on your data
@ram-bot
all(isEmpty, values({a: null, b: null}))
ram-bot
@ram-bot
Feb 22 2018 19:27
false
Bijoy Thomas
@bijoythomas
Feb 22 2018 19:27
you may want to couple it will isNil
@ram-bot
all(either(isEmpty, isNil), values({a: null, b: null}))
ram-bot
@ram-bot
Feb 22 2018 19:27
true
David
@DavidBernal
Feb 22 2018 19:28
In my case the values will be always a string
but thanks for the suggestion
Bijoy Thomas
@bijoythomas
Feb 22 2018 19:29
yw
Denis Stoyanov
@xgrommx
Feb 22 2018 19:45
@DavidBernal compose(reduce(useWith(and, [identity, isEmpty]), true), values)({one: '', two: ''})
I forgot about all =)
functionalStoic
@functionalStoic
Feb 22 2018 23:39
@lax4mike Thanks for sharing your slides above. Good simple intro for explaining reasons to use FP/Ramda
Mike Lambert
@lax4mike
Feb 22 2018 23:57
👍