문제

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?

도움이 되었습니까?

해결책

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
}

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top