Created
April 8, 2021 17:52
-
-
Save rocky-jaiswal/c387f16a23340c1ca5b0bd15f2af82d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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