mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
Add validation for label name and color.
This commit is contained in:
@@ -14,13 +14,13 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
case class LabelForm(labelName: String, color: String)
|
case class LabelForm(labelName: String, color: String)
|
||||||
|
|
||||||
val newForm = mapping(
|
val newForm = mapping(
|
||||||
"newLabelName" -> trim(label("Label name", text(required, maxlength(100)))),
|
"newLabelName" -> trim(label("Label name", text(required, identifier, maxlength(100)))),
|
||||||
"newColor" -> trim(label("Color", text(required, maxlength(7))))
|
"newColor" -> trim(label("Color", text(required, color)))
|
||||||
)(LabelForm.apply)
|
)(LabelForm.apply)
|
||||||
|
|
||||||
val editForm = mapping(
|
val editForm = mapping(
|
||||||
"editLabelName" -> trim(label("Label name", text(required, maxlength(100)))),
|
"editLabelName" -> trim(label("Label name", text(required, identifier, maxlength(100)))),
|
||||||
"editColor" -> trim(label("Color", text(required, maxlength(7))))
|
"editColor" -> trim(label("Color", text(required, color)))
|
||||||
)(LabelForm.apply)
|
)(LabelForm.apply)
|
||||||
|
|
||||||
post("/:owner/:repository/issues/label/new", newForm)(writableRepository { form =>
|
post("/:owner/:repository/issues/label/new", newForm)(writableRepository { form =>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ trait Validations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def color = pattern("#[0-9a-fA-F]{6}")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ValueType for the java.util.Date property.
|
* ValueType for the java.util.Date property.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user