From 8248449c5bb8295e7f246818eb5fa19c34c7da2c Mon Sep 17 00:00:00 2001 From: Ashraf Alhaj <87209980+ISNewton@users.noreply.github.com> Date: Sun, 13 Oct 2024 10:54:18 +0200 Subject: [PATCH] fix: exam title valdiation --- .env | 1 - .example.env | 2 ++ cmd/api/exam_handler.go | 4 ++-- cmd/api/main.go | 4 +++- example.env | 1 - 5 files changed, 7 insertions(+), 5 deletions(-) delete mode 100644 .env create mode 100644 .example.env delete mode 100644 example.env diff --git a/.env b/.env deleted file mode 100644 index 6bef1af..0000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -DATABASE_URL=postgres://peter:password@localhost:5432/suhail \ No newline at end of file diff --git a/.example.env b/.example.env new file mode 100644 index 0000000..53501a1 --- /dev/null +++ b/.example.env @@ -0,0 +1,2 @@ +DATABASE_URL=postgres://username:password@localhost:5432/database_name +APP_PORT=4000 \ No newline at end of file diff --git a/cmd/api/exam_handler.go b/cmd/api/exam_handler.go index 32a1bbe..71ce59b 100644 --- a/cmd/api/exam_handler.go +++ b/cmd/api/exam_handler.go @@ -79,7 +79,7 @@ func (config *Config) createExam(c echo.Context) error { var examSchema types.ExamInput rules := govalidator.MapData{ - "exam_title": []string{"required", "min:4", "max:30"}, + "exam_title": []string{"required", "min:4", "max:255"}, "status": []string{"required", "in:public,private"}, "questions": []string{"required"}, } @@ -639,7 +639,7 @@ func (config *Config) checkExamTitle(c echo.Context) error { var examSchema types.ExamInput rules := govalidator.MapData{ - "exam_title": []string{"required", "min:4", "max:30"}, + "exam_title": []string{"required", "min:4", "max:255"}, } opts := govalidator.Options{ diff --git a/cmd/api/main.go b/cmd/api/main.go index e759ef9..8dfb41a 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -55,5 +55,7 @@ func main() { registerApiRoutes(e, config) - e.Logger.Fatal(e.Start(":4000")) + appPort := os.Getenv("APP_PORT") + + e.Logger.Fatal(e.Start(":" + appPort)) } diff --git a/example.env b/example.env deleted file mode 100644 index 8b6b9da..0000000 --- a/example.env +++ /dev/null @@ -1 +0,0 @@ -DATABASE_URL=postgres://username:password@localhost:5432/db