Trim whitespace from names of objects on save

This commit is contained in:
Jamie Curnow
2023-01-10 12:50:46 +10:00
parent 6d0bf1c68b
commit 8033d052fe
3 changed files with 10 additions and 0 deletions

View File

@ -55,6 +55,9 @@ func (m *Model) Touch(created bool) {
func (m *Model) Save() error {
var err error
// ensure name is trimmed of whitespace
m.Name = strings.TrimSpace(m.Name)
if m.ID == 0 {
m.ID, err = Create(m)
} else {