MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / validate

Method validate

auth/user.go:146–160  ·  view source on GitHub ↗

Checks whether this userImpl object contains valid data; if not, returns an error.

()

Source from the content-addressed store, hash-verified

144
145// Checks whether this userImpl object contains valid data; if not, returns an error.
146func (user *userImpl) validate() error {
147 if err := (&user.roleImpl).validate(); err != nil {
148 return err
149 } else if user.Email_ != "" && !IsValidEmail(user.Email_) {
150 return base.HTTPErrorf(http.StatusBadRequest, "Invalid email address")
151 } else if user.OldPasswordHash_ != nil {
152 return base.HTTPErrorf(http.StatusBadRequest, "Obsolete password hash present")
153 }
154 for roleName := range user.ExplicitRoles_ {
155 if !IsValidPrincipalName(roleName) {
156 return base.HTTPErrorf(http.StatusBadRequest, "Invalid role name %q", roleName)
157 }
158 }
159 return nil
160}
161
162// Key used in 'access' view (not same meaning as doc ID)
163func (user *userImpl) accessViewKey() string {

Callers

nothing calls this directly

Calls 4

HTTPErrorfFunction · 0.92
IsValidEmailFunction · 0.85
IsValidPrincipalNameFunction · 0.85
validateMethod · 0.65

Tested by

no test coverage detected