Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/project/api/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (
func ValidateProject(project *api.Project) errors.ValidationErrorList {
result := errors.ValidationErrorList{}
if len(project.Name) == 0 {
result = append(result, errors.NewFieldRequired("Name", project.Name))
} else if !util.IsDNS952Label(project.Name) {
result = append(result, errors.NewFieldInvalid("Name", project.Name, "does not conform to lower-cased dns952"))
result = append(result, errors.NewFieldRequired("name", project.Name))
} else if !util.IsDNSSubdomain(project.Name) {
result = append(result, errors.NewFieldInvalid("name", project.Name, "does not conform to lower-cased dns1123"))
}
if len(project.Namespace) > 0 {
result = append(result, errors.NewFieldInvalid("Namespace", project.Namespace, "must be the empty-string"))
result = append(result, errors.NewFieldInvalid("namespace", project.Namespace, "must be the empty-string"))
}
if !validateNoNewLineOrTab(project.DisplayName) {
result = append(result, errors.NewFieldInvalid("DisplayName", project.DisplayName, "may not contain a new line or tab"))
result = append(result, errors.NewFieldInvalid("displayName", project.DisplayName, "may not contain a new line or tab"))
}
return result
}
Expand Down
27 changes: 27 additions & 0 deletions pkg/project/api/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,33 @@ func TestValidateProject(t *testing.T) {
// Should fail because the ID is invalid.
numErrs: 1,
},
{
name: "invalid id uppercase",
project: api.Project{
ObjectMeta: kapi.ObjectMeta{
Name: "A",
},
},
numErrs: 1,
},
{
name: "valid id leading number",
project: api.Project{
ObjectMeta: kapi.ObjectMeta{
Name: "1",
},
},
numErrs: 0,
},
{
name: "valid id internal dots",
project: api.Project{
ObjectMeta: kapi.ObjectMeta{
Name: "1.a.1",
},
},
numErrs: 0,
},
{
name: "has namespace",
project: api.Project{
Expand Down