21 lines
425 B
Go
21 lines
425 B
Go
package drama
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
const MaxEpisodeCharacters = 5000
|
|
|
|
func ValidateEpisodeContent(content string) error {
|
|
count := utf8.RuneCountInString(strings.TrimSpace(content))
|
|
if count == 0 {
|
|
return fmt.Errorf("剧集原文不能为空")
|
|
}
|
|
if count > MaxEpisodeCharacters {
|
|
return fmt.Errorf("每集原文不能超过%d字,当前%d字", MaxEpisodeCharacters, count)
|
|
}
|
|
return nil
|
|
}
|