Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

User map/collect instead of fold

  • Loading branch information...
commit 6377e7c8372e53967ba6280421e14170e8679cfa 1 parent 6e3dc80
Tymon Tobolski authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/main/scala/com/verknowsys/forms/Form.scala
4 src/main/scala/com/verknowsys/forms/Form.scala
View
@@ -15,9 +15,9 @@ abstract class Field[Entity, T](val name: String, getter: Entity => T, validator
lazy val (value, errors) = calculateValue
- def calculateValue: (Option[T], List[String]) = {
+ def calculateValue: (Option[T], Seq[String]) = {
val value = form.params.get(name).map(decode) getOrElse form.entity.map(getter)
- val errors = value map { v => (List[String]() /: validators){ (list, f) => f(v).toList ::: list } } getOrElse Nil
+ val errors = value map { v => validators.view map {_(v)} collect { case Some(e) => e } } getOrElse Nil
(value, errors)
}
Please sign in to comment.
Something went wrong with that request. Please try again.