Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate new user name, email, password in update api #510

Merged
merged 3 commits into from
Jan 12, 2021

Conversation

micossow
Copy link
Contributor

No description provided.

private def validatePassword(password: String) =
UserRegisterValidator
.validatePassword(password)
.fold(msg => Fail.IncorrectInput(msg).raiseError[ConnectionIO, Unit], _ => ().pure[ConnectionIO])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've got the .fold(...) in a couple of places now, I'm wondering if there's a way to simplify that. Maybe have a UserValidator instead of UserRegisterValidator which would accept optional login/email/password and validate the ones that are present? Then we could also have a single method which converts the Either into a Task.


def validateLogin(login: String): Either[String, Unit] =
if (login.length >= MinLoginLength) ValidationOk else Left("Login is too short!")
def asTask(): ConnectionIO[Unit] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more change - that's not really a Task we are returning, but a ConnectionIO. So this needs renaming, or generalisation into a def as[F: MonadError]: F[Unit]

@adamw adamw merged commit ec778c6 into master Jan 12, 2021
@mergify mergify bot deleted the feature/details-update-validation branch January 12, 2021 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants