1package validator
2
3import (
4 "errors"
5 "fmt"
6 "unicode/utf8"
7
8 "tangled.org/core/appview/models"
9)
10
11func (v *Validator) ValidateString(s *models.String) error {
12 var err error
13
14 if utf8.RuneCountInString(s.Filename) > 140 {
15 err = errors.Join(err, fmt.Errorf("filename too long"))
16 }
17
18 if utf8.RuneCountInString(s.Description) > 280 {
19 err = errors.Join(err, fmt.Errorf("description too long"))
20 }
21
22 if len(s.Contents) == 0 {
23 err = errors.Join(err, fmt.Errorf("contents is empty"))
24 }
25
26 return err
27}