Search code examples
scalalift

Does lift have validation for urls?


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?


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
    }