(refs #802)Allow '+' in repository name

This commit is contained in:
Naoki Takezoe
2015-07-03 21:40:26 +09:00
parent 10ffb452d0
commit 3d5e4a4225
2 changed files with 19 additions and 2 deletions

View File

@@ -91,7 +91,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
val newRepositoryForm = mapping(
"owner" -> trim(label("Owner" , text(required, maxlength(40), identifier, existsAccount))),
"name" -> trim(label("Repository name", text(required, maxlength(40), identifier, uniqueRepository))),
"name" -> trim(label("Repository name", text(required, maxlength(40), repository, uniqueRepository))),
"description" -> trim(label("Description" , optional(text()))),
"isPrivate" -> trim(label("Repository Type", boolean())),
"createReadme" -> trim(label("Create README" , boolean()))

View File

@@ -6,7 +6,7 @@ import org.scalatra.i18n.Messages
trait Validations {
/**
* Constraint for the identifier such as user name, repository name or page name.
* Constraint for the identifier such as user name or page name.
*/
def identifier: Constraint = new Constraint(){
override def validate(name: String, value: String, messages: Messages): Option[String] =
@@ -19,6 +19,23 @@ trait Validations {
}
}
/**
* Constraint for the repository identifier.
*/
def repository: Constraint = new Constraint(){
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("-")){
Some(s"${name} starts with invalid character.")
} else {
None
}
}
/**
* Constraint for the color pattern.
*/
def color = pattern("#[0-9a-fA-F]{6}")
/**