aboutsummaryrefslogtreecommitdiff
path: root/ui/form/api_key.go
blob: a30dcb0bdfc4fccc004b5fc23762f7a21b98c8fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2020 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.

package form // import "miniflux.app/ui/form"

import (
	"net/http"

	"miniflux.app/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"),
	}
}