mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 06:55:54 +01:00
Upgrade to scalatra-forms 0.0.4
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import jp.sf.amateras.scalatra.forms._
|
||||
import org.scalatra.i18n.Messages
|
||||
|
||||
trait Validations {
|
||||
|
||||
@@ -8,7 +9,7 @@ trait Validations {
|
||||
* Constraint for the identifier such as user name, repository name or page name.
|
||||
*/
|
||||
def identifier: Constraint = new Constraint(){
|
||||
override def validate(name: String, value: String): Option[String] =
|
||||
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
||||
if(!value.matches("^[a-zA-Z0-9\\-_.]+$")){
|
||||
Some(s"${name} contains invalid character.")
|
||||
} else if(value.startsWith("_") || value.startsWith("-")){
|
||||
@@ -25,7 +26,7 @@ trait Validations {
|
||||
*/
|
||||
def date(constraints: Constraint*): SingleValueType[java.util.Date] =
|
||||
new SingleValueType[java.util.Date]((pattern("\\d{4}-\\d{2}-\\d{2}") +: constraints): _*){
|
||||
def convert(value: String): java.util.Date = new java.text.SimpleDateFormat("yyyy-MM-dd").parse(value)
|
||||
def convert(value: String, messages: Messages): java.util.Date = new java.text.SimpleDateFormat("yyyy-MM-dd").parse(value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user