4
0

api_key.go 709 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2020 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package form // import "miniflux.app/ui/form"
  5. import (
  6. "net/http"
  7. "miniflux.app/errors"
  8. )
  9. // APIKeyForm represents the API Key form.
  10. type APIKeyForm struct {
  11. Description string
  12. }
  13. // Validate makes sure the form values are valid.
  14. func (a APIKeyForm) Validate() error {
  15. if a.Description == "" {
  16. return errors.NewLocalizedError("error.fields_mandatory")
  17. }
  18. return nil
  19. }
  20. // NewAPIKeyForm returns a new APIKeyForm.
  21. func NewAPIKeyForm(r *http.Request) *APIKeyForm {
  22. return &APIKeyForm{
  23. Description: r.FormValue("description"),
  24. }
  25. }