mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-21 19:37:41 +00:00
Fix Subreddit length
This commit is contained in:
parent
1919b36f57
commit
69a9101499
2 changed files with 2 additions and 1 deletions
|
@ -39,7 +39,7 @@ func validPrefix(value interface{}) error {
|
|||
|
||||
func (sr *Subreddit) Validate() error {
|
||||
return validation.ValidateStruct(sr,
|
||||
validation.Field(&sr.Name, validation.Required, validation.Length(2, 32), validation.By(validPrefix), validation.Match(regexp.MustCompile(`^[a-zA-Z0-9]\w{1,19}$`))),
|
||||
validation.Field(&sr.Name, validation.Required, validation.Length(2, 21), validation.By(validPrefix), validation.Match(regexp.MustCompile(`^[a-zA-Z0-9]\w*$`))),
|
||||
validation.Field(&sr.SubredditID, validation.Required, validation.Length(4, 9)),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ func TestValidate(t *testing.T) {
|
|||
"valid subreddit starting with u": {domain.Subreddit{Name: "urcool", SubredditID: "abcd"}, nil},
|
||||
"valid subreddit with _": {domain.Subreddit{Name: "p_i_x_a_r", SubredditID: "abcd"}, nil},
|
||||
"valid subreddit with 2 letters": {domain.Subreddit{Name: "de", SubredditID: "abcd"}, nil},
|
||||
"valid subreddit with 21 letters": {domain.Subreddit{Name: "GamingLeaksAndRumours", SubredditID: "abcd"}, nil},
|
||||
}
|
||||
|
||||
for scenario, tc := range tt {
|
||||
|
|
Loading…
Reference in a new issue