Skip to content

Instantly share code, notes, and snippets.

@joaocarvalhowd
Created March 30, 2020 17:39
Show Gist options
  • Save joaocarvalhowd/b7e8199872bcc4e0e8393184d4143322 to your computer and use it in GitHub Desktop.
Save joaocarvalhowd/b7e8199872bcc4e0e8393184d4143322 to your computer and use it in GitHub Desktop.
const {
all,
is,
isEmpty,
isNil,
or,
toPairs
} = require('ramda')
const isNilOrEmpty = value => or(isNil(value), isEmpty(value))
const propertyHasValue = ([key, value]) => {
if (is(Object, value)) {
return propertiesHasValues(value)
}
return !isNilOrEmpty(value)
}
const propertiesHasValues = obj => {
if (isNilOrEmpty(obj)) return false
return all(propertyHasValue)(toPairs(obj))
}
module.exports = propertiesHasValues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment