go scratch code for atproto
1package lexlint
2
3import (
4 "errors"
5 "regexp"
6)
7
8var schemaNameRegex = regexp.MustCompile(`^[a-zA-Z]([a-zA-Z0-9]{0,255})?$`)
9
10func CheckSchemaName(raw string) error {
11 if raw == "" {
12 return errors.New("empty name")
13 }
14 if len(raw) > 255 {
15 return errors.New("name is too long (255 chars max)")
16 }
17 if !schemaNameRegex.MatchString(raw) {
18 return errors.New("name doesn't match recommended syntax/characters")
19 }
20 return nil
21}