MCPcopy
hub / github.com/dnote/dnote / BookName

Function BookName

pkg/cli/validate/books.go:53–75  ·  view source on GitHub ↗

BookName validates a book name

(name string)

Source from the content-addressed store, hash-verified

51
52// BookName validates a book name
53func BookName(name string) error {
54 if name == "" {
55 return ErrBookNameEmpty
56 }
57
58 if isReservedName(name) {
59 return ErrBookNameReserved
60 }
61
62 if utils.IsNumber(name) {
63 return ErrBookNameNumeric
64 }
65
66 if strings.Contains(name, " ") {
67 return ErrBookNameHasSpace
68 }
69
70 if strings.Contains(name, "\n") || strings.Contains(name, "\r\n") {
71 return ErrBookNameMultiline
72 }
73
74 return nil
75}

Callers 3

newRunFunction · 0.92
runBookFunction · 0.92
TestValidateBookNameFunction · 0.85

Calls 2

IsNumberFunction · 0.92
isReservedNameFunction · 0.85

Tested by 1

TestValidateBookNameFunction · 0.68