Undistraction
Undistraction

Reputation: 43591

Ramda Negation In Both

Why does the following fail to return a function?

const isValid = both(not(isEmpty), is(Object));

The item is valid if it:

  1. Exists
  2. Is an Array
  3. Is not empty

Upvotes: 2

Views: 1191

Answers (1)

Oliver Baumann
Oliver Baumann

Reputation: 2289

As mentioned in my comment, not is, ahem, not what you want. Instead, try complement:

const isValid = R.both(R.complement(R.isEmpty), R.is(Array));
console.log(isValid);
console.log(isValid([1,2,3]));
<script src="https://cdn.jsdelivr.net/npm/ramda@latest/dist/ramda.min.js"></script>

Upvotes: 5

Related Questions