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

AsyncValidator deal with Future failure while using ruleField #15

Open
rwalerow opened this issue Apr 7, 2018 · 0 comments
Open

AsyncValidator deal with Future failure while using ruleField #15

rwalerow opened this issue Apr 7, 2018 · 0 comments

Comments

@rwalerow
Copy link
Collaborator

rwalerow commented Apr 7, 2018

At the moment AsynValidator api doesn't provide a way to deal with Future errors while using ruleField.

It would be nice to give users a possibility to handle error cases somehow similar to regular rule method.

  • def ruleCatchOnly(...)
  • def ruleCatchNonFatal(...)

How about something like this?:

  • def ruleFieldCatchOnly(...)
  • def ruleFieldCatchNonFatal(...)

If it were possible it would also be nice to give users a possibility to default future error handler for all field validators. With that in mind, the user could handle all errors similarly without additional boilerplate.

Example proposition:

def isUsernameUniquie(username: Username): Future[Boolean] = ???
def isEmailUnique(email: Email): Future[Boolean] = ???

implicit val userValidator = Validator[User]
    .async
    .filedErrorHandler(throwable => "Error ocurred")
    .ruleField('username, isUsernameUniquie, "Username not unique")
    .ruleField('email, isEmailUnique, "Email not unique)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant