Skip to content

Instantly share code, notes, and snippets.

@rjhilgefort
Created August 8, 2018 20:02
Show Gist options
  • Save rjhilgefort/2b4d274633866935a49267b453033150 to your computer and use it in GitHub Desktop.
Save rjhilgefort/2b4d274633866935a49267b453033150 to your computer and use it in GitHub Desktop.
// validateRequired :: [String] | String a -> a | ThrownError
const validateRequired = propOrPath => R.cond([
[isString, R.compose(validateRequired, R.of)],
[R.T, path => R.when(
R.pathSatisfies(R.isNil, path),
R.compose(
fpThrow,
R.always(`"${path}" is required and must be present`),
)
)]
])(propOrPath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment