Created
May 13, 2019 15:32
-
-
Save basilboli/52a1aa04daf3355367a9c73bd60c1a4f 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
package io.xendera.framework.server.constraints | |
import play.api.data.{Forms, Mapping} | |
import play.api.data.validation.{Constraint, Invalid, Valid, ValidationError} | |
object FormConstraints { | |
private val PasswordConstraint = "constraint.xendera.password" | |
private val MinLengthMessage = PasswordConstraint + ".error.minLength" | |
private val MinLength = 8 | |
private def passwordConstraint: Constraint[String] = | |
Constraint[String](PasswordConstraint) { v => | |
if (v != null && v.length >= MinLength) Valid else Invalid(ValidationError(MinLengthMessage, MinLength)) | |
} | |
val password: Mapping[String] = Forms.text.verifying(passwordConstraint) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment