Skip to content

Instantly share code, notes, and snippets.

@rocky-jaiswal
Created April 8, 2021 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rocky-jaiswal/c387f16a23340c1ca5b0bd15f2af82d4 to your computer and use it in GitHub Desktop.
Save rocky-jaiswal/c387f16a23340c1ca5b0bd15f2af82d4 to your computer and use it in GitHub Desktop.
const isPresent = complement(isNil)
const isAllowed = (val) => ['foo', 'bar'].includes(val)
const hasChildWithProp = propSatisfies(isAllowed, 'x')
const validResponseInEnum = allPass([isPresent, isAllowed])
const validResponseWithProp = allPass([isPresent, hasChildWithProp])
console.log(validResponseInEnum(null))
console.log(validResponseInEnum('foo'))
console.log(validResponseWithProp({y: 'foo'}))
console.log(validResponseWithProp({x: 'foo'}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment