mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-22 03:37:43 +00:00
fix subreddit watchers for 2 letter subreddits
This commit is contained in:
parent
132374fb6b
commit
1919b36f57
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(3, 32), validation.By(validPrefix), validation.Match(regexp.MustCompile(`^[a-zA-Z0-9]\w{1,19}$`))),
|
||||
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.SubredditID, validation.Required, validation.Length(4, 9)),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ func TestValidate(t *testing.T) {
|
|||
"valid subreddit": {domain.Subreddit{Name: "pics", SubredditID: "abcd"}, nil},
|
||||
"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},
|
||||
}
|
||||
|
||||
for scenario, tc := range tt {
|
||||
|
|
Loading…
Reference in a new issue