Skip to content

Instantly share code, notes, and snippets.

@remeniuk
Created February 24, 2015 19:08
Show Gist options
  • Save remeniuk/a9bd7ae2321260f29cae to your computer and use it in GitHub Desktop.
Save remeniuk/a9bd7ae2321260f29cae to your computer and use it in GitHub Desktop.
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
}
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