Skip to content

Commit dcb46d5

Browse files
authored
feat: additional request validation (#59)
PLAT-86
2 parents 778798e + 4ac0465 commit dcb46d5

File tree

25 files changed

+1926
-359
lines changed

25 files changed

+1926
-359
lines changed

api/v1/design/common.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ import (
44
g "goa.design/goa/v3/dsl"
55
)
66

7-
// Allows IDs that are:
8-
// - 1-63 characters
9-
// - Contain only lower-cased letters and hyphens
10-
// - Starts with a letter or number
11-
// - Ends with a letter or number
12-
// The handlers must also validate that there are no consecutive hyphens.
13-
const idPattern = `^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$`
14-
157
var Identifier = g.Type("Identifier", g.String, func() {
168
g.Description("A user-specified identifier. Must be 1-63 characters, contain only lower-cased letters and hyphens, start and end with a letter or number, and not contain consecutive hyphens.")
17-
g.Pattern(idPattern)
9+
// Intentionally not using a pattern here for two reasons:
10+
// - Go regex doesn't support lookahead, so we can't express the consecutive
11+
// hyphen rule.
12+
// - The pattern is somewhat complex, so the error message is hard to
13+
// interpret when the value doesn't match.
14+
g.MinLength(1)
15+
g.MaxLength(63)
1816
g.Example("production")
1917
g.Example("my-app")
2018
g.Example("76f9b8c0-4958-11f0-a489-3bb29577c696")

api/v1/design/database.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ var HostIDs = g.ArrayOf(Identifier, func() {
1919
})
2020

2121
var DatabaseNodeSpec = g.Type("DatabaseNodeSpec", func() {
22-
// TODO: Validation to enforce that node names are unique within a database.
2322
g.Attribute("name", g.String, func() {
2423
g.Description("The name of the database node.")
2524
g.Pattern(nodeNamePattern)

api/v1/gen/control_plane/views/view.go

Lines changed: 68 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1/gen/http/control_plane/client/cli.go

Lines changed: 90 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)