Question

I want my users to be able to enter their webpage url when signing up.
Does lift have any built in support for url format validation?

Was it helpful?

Solution

AFAIK, no, but you can create a simple validation rule:

import java.net.{ URL, URISyntaxException };
import scala.util.Try

def isValidUrl(url: String): Boolean = {
  Try { val link = new URL(url); true } getOrElse false
}

OTHER TIPS

If your users have an HTML5 browser, you can use the SHtml.url function to generate an input that is validated client-side. This relies on the HTML type="url" attribute for an input and so is only supported in more modern browsers.

There is no server-side validation baked into Lift, but you can use any number of third party ones like Apache Commons or as @flavian mentioned, you can write your own.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top