diff options
author | 2023-08-10 19:46:45 -0700 | |
---|---|---|
committer | 2023-08-10 20:29:34 -0700 | |
commit | 168a870c025bfef6efdeb46e166e79a16093c157 (patch) | |
tree | 4d8ab69c7e3ef03a7ade06e7b5e5053429a64c3b /internal/ui/form/api_key.go | |
parent | c2349032552891745cbbc3d2a9e772845a0239f4 (diff) | |
download | v2-168a870c025bfef6efdeb46e166e79a16093c157.tar.gz v2-168a870c025bfef6efdeb46e166e79a16093c157.tar.zst v2-168a870c025bfef6efdeb46e166e79a16093c157.zip |
Move internal packages to an internal folder
For reference: https://go.dev/doc/go1.4#internalpackages
Diffstat (limited to 'internal/ui/form/api_key.go')
-rw-r--r-- | internal/ui/form/api_key.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/ui/form/api_key.go b/internal/ui/form/api_key.go new file mode 100644 index 00000000..1eb754bc --- /dev/null +++ b/internal/ui/form/api_key.go @@ -0,0 +1,31 @@ +// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +package form // import "miniflux.app/v2/internal/ui/form" + +import ( + "net/http" + + "miniflux.app/v2/internal/errors" +) + +// APIKeyForm represents the API Key form. +type APIKeyForm struct { + Description string +} + +// Validate makes sure the form values are valid. +func (a APIKeyForm) Validate() error { + if a.Description == "" { + return errors.NewLocalizedError("error.fields_mandatory") + } + + return nil +} + +// NewAPIKeyForm returns a new APIKeyForm. +func NewAPIKeyForm(r *http.Request) *APIKeyForm { + return &APIKeyForm{ + Description: r.FormValue("description"), + } +} |