diff --git a/backend/internal/data/repo/repo_notifier.go b/backend/internal/data/repo/repo_notifier.go index 077308d..c99cad2 100644 --- a/backend/internal/data/repo/repo_notifier.go +++ b/backend/internal/data/repo/repo_notifier.go @@ -43,7 +43,7 @@ type ( NotifierUpdate struct { Name string `json:"name" validate:"required,min=1,max=255"` IsActive bool `json:"isActive"` - URL *string `json:"url" extensions:"x-nullable" validate:"omitempty,shoutrrr"` + URL *string `json:"url" validate:"omitempty,shoutrrr" extensions:"x-nullable" ` } NotifierOut struct { diff --git a/backend/internal/sys/validate/validate.go b/backend/internal/sys/validate/validate.go index 3943b48..3d121de 100644 --- a/backend/internal/sys/validate/validate.go +++ b/backend/internal/sys/validate/validate.go @@ -11,7 +11,7 @@ var validate *validator.Validate func init() { validate = validator.New() - validate.RegisterValidation("shoutrrr", func(fl validator.FieldLevel) bool { + err := validate.RegisterValidation("shoutrrr", func(fl validator.FieldLevel) bool { prefixes := [...]string{ "discord://", "smtp://", @@ -45,6 +45,10 @@ func init() { return false }) + if err != nil { + panic(err) + } + } // Checks a struct for validation errors and returns any errors the occur. This diff --git a/frontend/lib/api/__test__/user/notifier.test.ts b/frontend/lib/api/__test__/user/notifier.test.ts index 717c03a..ed8e2ca 100644 --- a/frontend/lib/api/__test__/user/notifier.test.ts +++ b/frontend/lib/api/__test__/user/notifier.test.ts @@ -9,7 +9,7 @@ describe("basic notifier workflows", () => { // Create Notifier const result = await client.notifiers.create({ name: faker.name.firstName(), - url: faker.internet.url(), + url: "discord://" + faker.random.alphaNumeric(10), isActive: true, }); @@ -23,7 +23,7 @@ describe("basic notifier workflows", () => { { const updateData = { name: faker.name.firstName(), - url: faker.internet.url(), + url: "discord://" + faker.random.alphaNumeric(10), isActive: true, }; @@ -38,7 +38,7 @@ describe("basic notifier workflows", () => { { const updateData = { name: faker.name.firstName(), - url: "", + url: null, isActive: true, };