2023-06-19 17:42:47 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2020-03-01 20:38:29 -05:00
|
|
|
|
2023-08-10 22:46:45 -04:00
|
|
|
package form // import "miniflux.app/v2/internal/ui/form"
|
2020-03-01 20:38:29 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2023-10-21 22:50:29 -04:00
|
|
|
"miniflux.app/v2/internal/locale"
|
2020-03-01 20:38:29 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// APIKeyForm represents the API Key form.
|
|
|
|
type APIKeyForm struct {
|
|
|
|
Description string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate makes sure the form values are valid.
|
2023-10-21 22:50:29 -04:00
|
|
|
func (a APIKeyForm) Validate() *locale.LocalizedError {
|
2020-03-01 20:38:29 -05:00
|
|
|
if a.Description == "" {
|
2023-10-21 22:50:29 -04:00
|
|
|
return locale.NewLocalizedError("error.fields_mandatory")
|
2020-03-01 20:38:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewAPIKeyForm returns a new APIKeyForm.
|
|
|
|
func NewAPIKeyForm(r *http.Request) *APIKeyForm {
|
|
|
|
return &APIKeyForm{
|
|
|
|
Description: r.FormValue("description"),
|
|
|
|
}
|
|
|
|
}
|