commit c17077845bc162d631c074e7f1acfdac153f27ff
parent 2de11853868430dcf48120cdac738975693f83e0
Author: brookjeynes <me@brookjeynes.dev>
Date: Sun, 3 May 2026 17:20:23 +1000
refactor: make bio nullable
Signed-off-by: brookjeynes <me@brookjeynes.dev>
Diffstat:
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/internal/db/db.go b/internal/db/db.go
@@ -75,7 +75,7 @@ func Make(ctx context.Context, dbPath string) (*DB, error) {
create table if not exists artists (
id integer primary key autoincrement,
name text not null,
- bio text not null,
+ bio text,
created_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now'))
);
`)
diff --git a/internal/domain/artist.go b/internal/domain/artist.go
@@ -3,5 +3,5 @@ package domain
type Artist struct {
ID int64
Name string
- Bio string
+ Bio *string
}
diff --git a/internal/server/new-artist.go b/internal/server/new-artist.go
@@ -23,13 +23,13 @@ func parseNewArtistForm(form NewArtistForm) (domain.Artist, error) {
}
// bio
- if !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Bio) {
+ if form.Bio != "" && !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Bio) {
return artist, fmt.Errorf("Artist biography must not be empty or have leading/trailing whitespace")
}
artist = domain.Artist{
Name: form.Name,
- Bio: form.Bio,
+ Bio: &form.Bio,
}
return artist, nil