Created
February 24, 2015 19:08
-
-
Save remeniuk/a9bd7ae2321260f29cae 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
def validateProduct(product: Product): List[String] = | |
requiredFieldsArePresent(product) |+| | |
idHasPermittedLength(product) |+| | |
nameHasPermittedLength(product) |+| | |
rateTypeIsCPM(product) |+| | |
productIdIsUnique(product /*, mongoDao*/) |+| | |
productNameIsUnique(product /*, mongoDao*/) |+| | |
currencyIsISOCompliant(product) match { | |
case Failure(errors) => errors.toList | |
case _ => Nil | |
} |
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
implicit object ProductSemigroup extends Semigroup[Product] { | |
override def append(f1: Product, f2: => Product): Product = f1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment