// validReceiver reports whether recv is a valid receiver expression.
486287
func validReceiver(recv string) bool {
	if recv == "" {
		// The parse will parse empty receivers, but we don't want to accept them,
		// since it won't generate a usable code snippet.
		return false
	}
	fset := token.NewFileSet()
	_, err := parser.ParseFile(fset, "", "package hack\nfunc ("+recv+") Foo()", 0)
	return err == nil
}
497539
func (c *rawConnection) pingReceiver() error {
	ticker := time.NewTicker(ReceiveTimeout / 2)
	defer ticker.Stop()

	for {
		select {
		case <-ticker.C:
			d := time.Since(c.cr.Last())
			if d > ReceiveTimeout {
				l.Debugln(c.id, "ping timeout", d)
				return ErrTimeout
			}

			l.Debugln(c.id, "last read within", d)

		case <-c.closed:
			return ErrClosed
		}
	}
}
61693
func checkEncryptReceivers(receivers []BoxPublicKey) error {
	receiverCount := int64(len(receivers))
	if receiverCount <= 0 || receiverCount > maxReceiverCount {
		return ErrBadReceivers
	}

	// Make sure that each receiver only shows up in the set once.
	receiverSet := make(map[string]bool)

	// Make sure each key hasn't been used before.
	for _, receiver := range receivers {
		kid := receiver.ToKID()
		kidString := string(kid)
		if receiverSet[kidString] {
			return ErrRepeatedKey(kid)
		}
		receiverSet[kidString] = true
	}

	return nil
}
87827
func (c *Client) GetReceivedByAddress(address btcutil.Address) (btcutil.Amount, error) {
	return c.GetReceivedByAddressAsync(address).Receive()
}
201124
func (c *conditionalRule) Valid(ctx context.Context) bool {
	if !c.validPredicate() {
		return false
	}
	return true
}
990563
func (wfe *WebFrontEndImpl) validNonce(jws *jose.JSONWebSignature) *probs.ProblemDetails {
	// validNonce is called after validPOSTRequest() and parseJWS() which
	// defend against the incorrect number of signatures.
	header := jws.Signatures[0].Header
	nonce := header.Nonce
	if len(nonce) == 0 {
		wfe.stats.joseErrorCount.With(prometheus.Labels{"type": "JWSMissingNonce"}).Inc()
		return probs.BadNonce("JWS has no anti-replay nonce")
	} else if !wfe.nonceService.Valid(nonce) {
		wfe.stats.joseErrorCount.With(prometheus.Labels{"type": "JWSInvalidNonce"}).Inc()
		return probs.BadNonce("JWS has an invalid anti-replay nonce: %q", nonce)
	}
	return nil
}
778589
func (aabb *AABB) Valid() bool {
	return aabb.Lower.X <= aabb.Upper.X && aabb.Lower.Y <= aabb.Upper.Y
}
560297
func (m *ChannelMap) Valid() bool {
	cmap := m.toC()
	return C.pa_channel_map_valid(cmap) != 0
}
796839
func Valid(json string) bool {
	_, ok := validpayload(stringBytes(json), 0)
	return ok
}
549710
func ValidBrowsers() []string {
	keys := make([]string, 0, len(manifestPath[runtime.GOOS]))
	for k := range manifestPath[runtime.GOOS] {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	return keys
}
29699
func (c *Conn) lockedReceive() ([]Message, error) {
	msgs, err := c.receive()
	if err != nil {
		c.debug(func(d *debugger) {
			d.debugf(1, "recv: err: %v", err)
		})

		return nil, err
	}

	c.debug(func(d *debugger) {
		for _, m := range msgs {
			d.debugf(1, "recv: %+v", m)
		}
	})

	// When using nltest, it's possible for zero messages to be returned by receive.
	if len(msgs) == 0 {
		return msgs, nil
	}

	// Trim the final message with multi-part done indicator if
	// present.
	if m := msgs[len(msgs)-1]; m.Header.Flags&Multi != 0 && m.Header.Type == Done {
		return msgs[:len(msgs)-1], nil
	}

	return msgs, nil
}
841335
func (c *Conversation) receiveUnit(m ValidMessage, forgetFragments bool) (plain MessagePlaintext, toSend []ValidMessage, err error) {
	message := makeCopy(m)
	defer wipeBytes(message)

	if !c.Policies.isOTREnabled() {
		return c.receiveWithoutOTR(message)
	}

	msgType := guessMessageType(message)
	var messagesToSend []messageWithHeader
	shouldForgetFragment := true
	switch msgType {
	case msgGuessError:
		return c.withInjectionsPlain(c.receiveErrorMessage(message))
	case msgGuessQuery:
		messagesToSend, err = c.receiveQueryMessage(message)
	case msgGuessTaggedPlaintext:
		plain, messagesToSend, err = c.receiveTaggedPlaintext(message)
	case msgGuessNotOTR:
		plain, messagesToSend, err = c.receivePlaintext(message)
	case msgGuessV1KeyExch:
		return nil, nil, errUnsupportedOTRVersion
	case msgGuessFragment:
		shouldForgetFragment = false
		c.fragmentationContext, err = c.receiveFragment(c.fragmentationContext, message)
		if fragmentsFinished(c.fragmentationContext) {
			return c.withInjectionsPlain(c.receiveUnit(c.fragmentationContext.frag, false))
		}
	case msgGuessUnknown:
		c.messageEvent(MessageEventReceivedMessageUnrecognized)
	case msgGuessDHCommit, msgGuessDHKey, msgGuessRevealSig, msgGuessSignature, msgGuessData:
		plain, messagesToSend, err = c.receiveEncoded(encodedMessage(message))
	}

	if shouldForgetFragment && forgetFragments {
		c.fragmentationContext = forgetFragment()
	}

	return c.withInjectionsPlain(c.toSendEncoded(plain, messagesToSend, err))
}
321542
func (p *Provider) Valid(hash, plain []byte) bool {
	return gobcrypt.CompareHashAndPassword(hash, plain) == nil
}
479997
func newReceiver(ls linkSettings) *receiver {
	r := &receiver{link: link{linkSettings: ls}}
	r.endpoint.init(r.link.pLink.String())
	if r.capacity < 1 {
		r.capacity = 1
	}
	r.buffer = make(chan ReceivedMessage, r.capacity)
	r.handler().addLink(r.pLink, r)
	r.link.pLink.Open()
	if r.prefetch {
		r.flow(r.maxFlow())
	}
	return r
}
1056118
func (c ChatChannel) Valid() bool {
	if len(c.Name) == 0 {
		return false
	}
	if len(c.MembersType) > 0 && !isValidMembersType(c.MembersType) {
		return false
	}
	return true
}
1285373
func (r *StatementRequest) Valid(version ofxVersion) (bool, error) {
	if ok, err := r.TrnUID.Valid(); !ok {
		return false, err
	}
	if r.IncludePending && version < OfxVersion220 {
		return false, errors.New("StatementRequest.IncludePending invalid for OFX < 2.2")
	}
	if r.IncTranImg && version < OfxVersion210 {
		return false, errors.New("StatementRequest.IncTranImg invalid for OFX < 2.1")
	}
	return r.BankAcctFrom.Valid()
}
254529
func (c *Client) Valid() bool {
	if c == nil {
		return false
	}

	if c.Client == nil {
		return false
	}

	// Use arbitrary pointer field in the service content.
	// Doesn't matter which one, as long as it is populated by default.
	if c.ServiceContent.SessionManager == nil {
		return false
	}

	return true
}