Validate the `status` field in create subscriber API

This commit is contained in:
Kailash Nadh 2019-11-30 09:54:46 +05:30
parent ccd354df3f
commit c7fc1aa506
1 changed files with 5 additions and 1 deletions

View File

@ -561,7 +561,11 @@ func ValidateFields(s SubReq) error {
if !govalidator.IsByteLength(s.Name, 1, stdInputMaxLen) { if !govalidator.IsByteLength(s.Name, 1, stdInputMaxLen) {
return errors.New(`invalid or empty name "` + s.Name + `"`) return errors.New(`invalid or empty name "` + s.Name + `"`)
} }
if s.Status != models.SubscriberStatusEnabled &&
s.Status != models.SubscriberStatusDisabled &&
s.Status != models.SubscriberStatusBlackListed {
return errors.New(`invalid or empty status "` + s.Status + `"`)
}
return nil return nil
} }