ibmkhd
ibmkhd

Reputation: 799

Using Play2(Scala) validation without Forms

I want to use play2 validation framework but without using forms and bindings, i have a single string that i want to check if it's an email or not without re-implementing the validation functionality

e.g

Validation.emailAddress("")

I looked/tried into this class Validation.scala but didn't figure out how to use it :)

Upvotes: 0

Views: 140

Answers (1)

lpiepiora
lpiepiora

Reputation: 13749

In your tag you've stated that you're using Playframework 2.2. This method does not exist in Play 2.2 source code.

If there was one, you could call it just like this

import play.api.data.validation._
val validationResult = Constraints.emailAddress("[email protected]")

You can test it by copying the method from the sources you linked to or by using Play 2.3.

Upvotes: 1

Related Questions