-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.go
More file actions
43 lines (34 loc) · 855 Bytes
/
Copy pathform.go
File metadata and controls
43 lines (34 loc) · 855 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"strings"
)
type Form struct {
Index int
Action string
Method string
UsernameField string
PasswordField string
SelectField string
SelectOptions []string
Fields map[string]string
}
func (f *Form) Description() string {
parts := []string{fmt.Sprintf("Action: %s", f.Action)}
if f.UsernameField != "" {
parts = append(parts, fmt.Sprintf("Username: %s", f.UsernameField))
}
if f.PasswordField != "" {
parts = append(parts, fmt.Sprintf("Password: %s", f.PasswordField))
}
if f.SelectField != "" {
parts = append(parts, fmt.Sprintf("Select: %s", f.SelectField))
}
return strings.Join(parts, ", ")
}
func (f *Form) IsLoginForm() bool {
return f.UsernameField != "" && f.PasswordField != ""
}
func (f *Form) HasPasswordField() bool {
return f.PasswordField != ""
}