// ValidateFast checks format of a given email.
486302
func ValidateFast(email string) error {
	if len(email) < 6 || len(email) > 254 {
		return ErrInvalidFormat
	}

	at := strings.LastIndex(email, "@")
	if at <= 0 || at > len(email)-3 {
		return ErrInvalidFormat
	}

	user := email[:at]
	host := email[at+1:]

	if len(user) > 64 {
		return ErrInvalidFormat
	}
	if userDotRegexp.MatchString(user) || !userRegexp.MatchString(user) || !hostRegexp.MatchString(host) {
		return ErrInvalidFormat
	}

	return nil
}
1176285
func ValidateEmail(r *http.Request, name string) bool {
	return ValidateString(r, name, validEmail)
}
1173056
func (m *Service) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateSpec(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateStatus(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
800322
func Validate(request Message, replies []Message) error {
	for _, m := range replies {
		// Check for mismatched sequence, unless:
		//   - request had no sequence, meaning we are probably validating
		//     a multicast reply
		if m.Header.Sequence != request.Header.Sequence && request.Header.Sequence != 0 {
			return newOpError("validate", errMismatchedSequence)
		}

		// Check for mismatched PID, unless:
		//   - request had no PID, meaning we are either:
		//     - validating a multicast reply
		//     - netlink has not yet assigned us a PID
		//   - response had no PID, meaning it's from the kernel as a multicast reply
		if m.Header.PID != request.Header.PID && request.Header.PID != 0 && m.Header.PID != 0 {
			return newOpError("validate", errMismatchedPID)
		}
	}

	return nil
}
1236227
func (service *Service) EmailValidation(w http.ResponseWriter, request *http.Request) {

	service.handleEmailValidation(w, request, false)
}
862457
func (c *CronSchedule) Validate() error {
	if c.entry == "" {
		return ErrMissingCronEntry
	}
	_, err := cron.Parse(c.entry)
	if err != nil {
		return err
	}
	return nil
}
1044896
func (c *readyCommand) validate(expectedServerShortNonce *shortNonce, sk *precomputedKey) error {

	// FIXME: to support metadata, bump the size of this buffer.
	if c.curlen != 30 {
		return fmt.Errorf("wrong READY length %d", c.curlen)
	}

	srcHeader := c.buf[:6]
	srcUnprefixedNonce := c.buf[6 : 6+8]
	srcEncReadyBox := c.buf[6+8 : 6+8+16]

	/* Validate the header. */
	if bytes.Compare(srcHeader, []byte{5, 'R', 'E', 'A', 'D', 'Y'}) != 0 {
		return fmt.Errorf("malformed READY header")
	}

	/* Check the nonce. */
	cn, err := readShortNonce(srcUnprefixedNonce)
	if err != nil {
		return err
	}
	if !expectedServerShortNonce.same(cn) {
		return fmt.Errorf("server nonce not in sequence: %d != %d", expectedServerShortNonce.uint64(), cn)
	}
	prefixedNonce, _, err := expectedServerShortNonce.prefixAndBump(readyNoncePrefix)
	if err != nil {
		return err
	}

	/* Decrypt the ready box. */
	_, ok := box.OpenAfterPrecomputation(nil, srcEncReadyBox, &prefixedNonce, (*[32]byte)(sk))
	if !ok {
		return fmt.Errorf("cannot validate server ready box")
	}

	return nil
}
987973
func (sub *subscription) IsValid() bool {
	sub.Lock()
	defer sub.Unlock()
	if sub.inboxSub == nil {
		return false
	}
	return sub.inboxSub.IsValid()
}
575989
func (m *GrpcService_EnvoyGrpc) Validate() error {
	if m == nil {
		return nil
	}

	if len(m.GetClusterName()) < 1 {
		return GrpcService_EnvoyGrpcValidationError{
			field:  "ClusterName",
			reason: "value length must be at least 1 bytes",
		}
	}

	return nil
}
243540
func (m *GenericError) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateName(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
166407
func (m *SwaggerFlushInactiveAccessTokens) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateBody(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
1180906
func ValidateKey(key string) error {
	if len(key) <= keyMaxLength && keyRegex.MatchString(key) {
		return nil
	}
	return fmt.Errorf("invalid key: %q", key)
}
826505
func (s *SkipDays) Validate() error {
	skipDays := map[string]bool{
		"Monday":    true,
		"Tuesday":   true,
		"Wednesday": true,
		"Thursday":  true,
		"Friday":    true,
		"Saturday":  true,
		"Sunday":    true,
	}
	for _, day := range s.Days {
		if !skipDays[day] {
			return errors.New(ErrValidation, errorMessages, "skip day %q is invalid", day)
		}
	}
	return nil
}
1340890
func (v *TimeIsBeforeTime) IsValid(errors *validate.Errors) {
	if v.FirstTime.UnixNano() <= v.SecondTime.UnixNano() {
		return
	}

	if len(v.Message) > 0 {
		errors.Add(GenerateKey(v.FirstName), v.Message)
		return
	}

	errors.Add(GenerateKey(v.FirstName), fmt.Sprintf("%s must be before %s.", v.FirstName, v.SecondName))
}
345540
func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
	var (
		u          *User
		emails     = map[string]*User{}
		newCommits = list.New()
		e          = oldCommits.Front()
	)
	for e != nil {
		c := e.Value.(*git.Commit)

		if v, ok := emails[c.Author.Email]; !ok {
			u, _ = GetUserByEmail(c.Author.Email)
			emails[c.Author.Email] = u
		} else {
			u = v
		}

		newCommits.PushBack(UserCommit{
			User:   u,
			Commit: c,
		})
		e = e.Next()
	}
	return newCommits
}
419344
func (m *Mark) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateRemains(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
912422
func (e Email) Validate(_ interface{}) error {
	if govalidator.IsEmail(string(e)) {
		return nil
	}

	return errInvalidEmail
}