Created
September 7, 2013 15:27
-
-
Save remeniuk/6476563 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
val selectedBonusIdValidator = (form: Form[BonusForm]) => | |
(for { | |
value <- form.value | |
bonusId <- value.selectedBonusId | |
} yield form | |
) getOrElse form.withError("selectedBonusId", "You should select an item!") | |
val selectedBonusValueValidator = (form: Form[BonusForm]) => | |
(for { | |
value <- form.value | |
bonusId <- value.selectedBonusValue | |
} yield form | |
) getOrElse form.withError("selectedBonusValue", "You should provide the value!") | |
val form = (bonusForm.fill(formEntity) /: | |
List(selectedBonusIdValidator, selectedBonusValueValidator))((f, v) => v(f)) | |
if (form.hasErrors) ... else ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment