Skip to content

Instantly share code, notes, and snippets.

@sumanyu
Created December 2, 2014 21:28
Show Gist options
  • Save sumanyu/5e13470423109182c983 to your computer and use it in GitHub Desktop.
Save sumanyu/5e13470423109182c983 to your computer and use it in GitHub Desktop.
super.validatePowerSource match {
case Success(_) => this.successNel
case f@Failure(_) => f
}
Attemt
def singleValidation [A] (objectRef: A)(validation: ValidationNel[ValidationFailure, A]) = validation match {
case Success(_)=> objectRef.successNel
case f@Failure(_) => f
}
@SriramKeerthi
Copy link

def singleValidation[A](obj: A)(validationMethod: => ValidationNel[ValidationFailure, Any]): ValidationNel[ValidationFailure, A] = {
validationMethod match {
case Success() =>
obj.successNel
case f@Failure(
) =>
f
}
}

usage:

singleValidation(x) {
isPositive(x, "v", false)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment