// ValidateBasic performs basic validation.
484953
func (m *NewRoundStepMessage) ValidateBasic() error {
	if m.Height < 0 {
		return errors.New("Negative Height")
	}
	if m.Round < 0 {
		return errors.New("Negative Round")
	}
	if !m.Step.IsValid() {
		return errors.New("Invalid Step")
	}

	// NOTE: SecondsSinceStartTime may be negative

	if (m.Height == 1 && m.LastCommitRound != -1) ||
		(m.Height > 1 && m.LastCommitRound < -1) { // TODO: #2737 LastCommitRound should always be >= 0 for heights > 1
		return errors.New("Invalid LastCommitRound (for 1st block: -1, for others: >= 0)")
	}
	return nil
}
1275029
func validateInput(target interface{}) ErrorList {

	_, validationError := govalidator.ValidateStruct(target)
	if validationError != nil {

		errorList, isType := validationError.(govalidator.Errors)
		if isType {

			errors := ErrorList{}
			for _, singleErr := range errorList.Errors() {

				// parse out validation error
				goValidErr, _ := singleErr.(govalidator.Error)
				inputErr := InputError(goValidErr.Err.Error(), goValidErr.Name)

				errors = append(errors, inputErr)
			}

			return errors
		}
	}

	return nil
}
541355
func (binaryStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
	// TODO: validate
	return nil
}
259432
func validateBuilder(c *validation.Context, cfgBuilder *notifypb.Builder, builderNames stringset.Set) {
	if cfgBuilder.Bucket == "" {
		c.Errorf(requiredFieldError, "bucket")
	}
	if strings.HasPrefix(cfgBuilder.Bucket, "luci.") {
		// TODO(tandrii): change to warning once our validation library supports it.
		c.Errorf(`field "bucket" should not include legacy "luci.<project_name>." prefix, given %q`, cfgBuilder.Bucket)
	}
	if cfgBuilder.Name == "" {
		c.Errorf(requiredFieldError, "name")
	}
	if cfgBuilder.Repository != "" {
		if err := gitiles.ValidateRepoURL(cfgBuilder.Repository); err != nil {
			c.Errorf(badRepoURLError, cfgBuilder.Repository)
		}
	}
	fullName := fmt.Sprintf("%s/%s", cfgBuilder.Bucket, cfgBuilder.Name)
	if !builderNames.Add(fullName) {
		c.Errorf(duplicateBuilderError, fullName)
	}
}
1356457
func (v *Validation) Valid(obj interface{}, args ...string) (ok bool, err error) {
	err = v.validExec(obj, "", args...)
	if err != nil {
		fmt.Println(err)
		return
	}
	if !v.HasErrors() {
		if form, ok := obj.(ValidFormer); ok {
			form.Valid(v)
		}
	}
	ok = v.HasErrors() == false
	return
}
940776
func (f *Fpdf) HTMLBasicNew() (html HTMLBasicType) {
	html.pdf = f
	html.Link.ClrR, html.Link.ClrG, html.Link.ClrB = 0, 0, 128
	html.Link.Bold, html.Link.Italic, html.Link.Underscore = false, false, true
	return
}
987973
func (sub *subscription) IsValid() bool {
	sub.Lock()
	defer sub.Unlock()
	if sub.inboxSub == nil {
		return false
	}
	return sub.inboxSub.IsValid()
}
1266389
func BooleanValidator(input string) (interface{}, error) {
	if input == "" {
		return nil, nil
	}

	b, err := parseBool(input)
	if err != nil {
		return nil, err
	}

	return b, nil
}
741368
func (v *UUIDIsPresent) IsValid(errors *validate.Errors) {
	s := v.Field.String()
	if strings.TrimSpace(s) != "" && v.Field != uuid.Nil {
		return
	}

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

	errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name))
}
183351
func (b BankAcct) Valid() (bool, error) {
	if len(b.BankID) == 0 {
		return false, errors.New("BankAcct.BankID empty")
	}
	if len(b.AcctID) == 0 {
		return false, errors.New("BankAcct.AcctID empty")
	}
	if !b.AcctType.Valid() {
		return false, errors.New("Invalid or unspecified BankAcct.AcctType")
	}
	return true, nil
}
1137263
func (psh PartSetHeader) ValidateBasic() error {
	if psh.Total < 0 {
		return errors.New("Negative Total")
	}
	// Hash can be empty in case of POLBlockID.PartsHeader in Proposal.
	if err := ValidateHash(psh.Hash); err != nil {
		return errors.Wrap(err, "Wrong Hash")
	}
	return nil
}
466345
func (m *Macro) Valid() error {
	if m.Name == "" {
		return fmt.Errorf("name empty")
	}

	validTypes := map[string]bool{
		"constant": true,
		"map":      true,
		"query":    true,
	}

	if _, prs := validTypes[m.Arguments.Type]; !prs {
		return fmt.Errorf("invalid arguments type")
	}

	if len(m.Selected) == 0 {
		return fmt.Errorf("no selected values")
	}

	return nil
}
189032
func (db *Database) validateCallData(selector *string, data []byte, messages *core.ValidationMessages) {
	// If the data is empty, we have a plain value transfer, nothing more to do
	if len(data) == 0 {
		return
	}
	// Validate the call data that it has the 4byte prefix and the rest divisible by 32 bytes
	if len(data) < 4 {
		messages.Warn("Transaction data is not valid ABI (missing the 4 byte call prefix)")
		return
	}
	if n := len(data) - 4; n%32 != 0 {
		messages.Warn(fmt.Sprintf("Transaction data is not valid ABI (length should be a multiple of 32 (was %d))", n))
	}
	// If a custom method selector was provided, validate with that
	if selector != nil {
		if info, err := verifySelector(*selector, data); err != nil {
			messages.Warn(fmt.Sprintf("Transaction contains data, but provided ABI signature could not be matched: %v", err))
		} else {
			messages.Info(info.String())
			db.AddSelector(*selector, data[:4])
		}
		return
	}
	// No method selector was provided, check the database for embedded ones
	embedded, err := db.Selector(data[:4])
	if err != nil {
		messages.Warn(fmt.Sprintf("Transaction contains data, but the ABI signature could not be found: %v", err))
		return
	}
	if info, err := verifySelector(embedded, data); err != nil {
		messages.Warn(fmt.Sprintf("Transaction contains data, but provided ABI signature could not be varified: %v", err))
	} else {
		messages.Info(info.String())
	}
}
1000767
func GetBasicType(t string) string {
	tip := raml.Type{
		Type: t,
	}

	switch {
	case tip.IsArray():
		return tip.ArrayType()
	case tip.IsBidimensiArray():
		return tip.BidimensiArrayType()
	default:
		return t
	}
}
83041
func (blockID BlockID) ValidateBasic() error {
	// Hash can be empty in case of POLBlockID in Proposal.
	if err := ValidateHash(blockID.Hash); err != nil {
		return fmt.Errorf("Wrong Hash")
	}
	if err := blockID.PartsHeader.ValidateBasic(); err != nil {
		return fmt.Errorf("Wrong PartsHeader: %v", err)
	}
	return nil
}
1021298
func (cfg *P2PConfig) ValidateBasic() error {
	if cfg.MaxNumInboundPeers < 0 {
		return errors.New("max_num_inbound_peers can't be negative")
	}
	if cfg.MaxNumOutboundPeers < 0 {
		return errors.New("max_num_outbound_peers can't be negative")
	}
	if cfg.FlushThrottleTimeout < 0 {
		return errors.New("flush_throttle_timeout can't be negative")
	}
	if cfg.MaxPacketMsgPayloadSize < 0 {
		return errors.New("max_packet_msg_payload_size can't be negative")
	}
	if cfg.SendRate < 0 {
		return errors.New("send_rate can't be negative")
	}
	if cfg.RecvRate < 0 {
		return errors.New("recv_rate can't be negative")
	}
	return nil
}
622640
func (v *EmailLike) IsValid(errors *validate.Errors) {
	parts := strings.Split(v.Field, "@")
	if len(parts) != 2 || len(parts[0]) == 0 || len(parts[1]) == 0 {
		if v.Message == "" {
			v.Message = fmt.Sprintf("%s does not match the email format.", v.Name)
		}
		errors.Add(GenerateKey(v.Name), v.Message)
	} else if len(parts) == 2 {
		domain := parts[1]
		// Check that domain is valid
		if len(strings.Split(domain, ".")) < 2 {
			if v.Message == "" {
				v.Message = fmt.Sprintf("%s does not match the email format (email domain).", v.Name)
			}
			errors.Add(GenerateKey(v.Name), v.Message)
		}
	}
}