Created
August 13, 2018 00:18
-
-
Save suzdalnitski/06a8cbf974db3271d6d46339a317bea9 to your computer and use it in GitHub Desktop.
This file contains 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
import { withProps } from "recompose"; | |
const getConfirmPasswordError = (password, confirmPassword) => { | |
if (!confirmPassword.isDirty) { | |
return ""; | |
} | |
const passwordsMatch = password.value === confirmPassword.value; | |
return !passwordsMatch ? "Passwords don't match." : ""; | |
}; | |
const withConfirmPasswordError = withProps( | |
(ownerProps) => ({ | |
confirmPasswordError: getConfirmPasswordError( | |
ownerProps.password, | |
ownerProps.confirmPassword | |
) | |
}) | |
); | |
export default withConfirmPasswordError; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment