Skip to content

Instantly share code, notes, and snippets.

@suzdalnitski
Created August 13, 2018 00:18
Show Gist options
  • Save suzdalnitski/06a8cbf974db3271d6d46339a317bea9 to your computer and use it in GitHub Desktop.
Save suzdalnitski/06a8cbf974db3271d6d46339a317bea9 to your computer and use it in GitHub Desktop.
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