// EnterVerifyDefault requests that the user enter a value.  Values failing to
// verify will be rejected with the error message returned by verify.  An empty
// string will be accepted as the default value even if it would fail
// verification.
767514
func (p *Pollster) EnterVerifyDefault(valueName string, verify VerifyFunc, defVal string) (string, error) {
	var verifyDefault VerifyFunc
	if verify != nil {
		verifyDefault = func(s string) (ok bool, errmsg string, err error) {
			if s == "" {
				return true, "", nil
			}
			return verify(s)
		}
	}
	s, err := QueryVerify("Enter "+valueName+" ["+defVal+"]: ", p.scanner, p.out, p.errOut, verifyDefault)
	if err != nil {
		return "", errors.Trace(err)
	}
	if s == "" {
		return defVal, nil
	}
	return s, nil
}
1265235
func (p *Pollster) Enter(valueName string) (string, error) {
	return p.EnterVerify(valueName, func(s string) (ok bool, msg string, err error) {
		return s != "", "", nil
	})
}
508359
func (s *APNSSandboxChannelResponse) SetDefaultAuthenticationMethod(v string) *APNSSandboxChannelResponse {
	s.DefaultAuthenticationMethod = &v
	return s
}
786915
func (c *Config) CheckDefaults() error {
	if c.ServiceName == "" {
		return trace.BadParameter("required parameter ServiceName missing")
	}
	if c.Username == "" {
		return trace.BadParameter("required parameter Username missing")
	}
	if c.Stdin == nil {
		return trace.BadParameter("required parameter Stdin missing")
	}
	if c.Stdout == nil {
		return trace.BadParameter("required parameter Stdout missing")
	}
	if c.Stderr == nil {
		return trace.BadParameter("required parameter Stderr missing")
	}

	return nil
}
843156
func (i Isolation) IsDefault() bool {
	return strings.ToLower(string(i)) == "default" || string(i) == ""
}
467242
func DefaultValuesOfCorrectTypeRule(context *ValidationContext) *ValidationRuleInstance {
	visitorOpts := &visitor.VisitorOptions{
		KindFuncMap: map[string]visitor.NamedVisitFuncs{
			kinds.VariableDefinition: {
				Kind: func(p visitor.VisitFuncParams) (string, interface{}) {
					if varDefAST, ok := p.Node.(*ast.VariableDefinition); ok {
						var (
							name         string
							defaultValue = varDefAST.DefaultValue
							messagesStr  string
						)
						if varDefAST.Variable != nil && varDefAST.Variable.Name != nil {
							name = varDefAST.Variable.Name.Value
						}
						ttype := context.InputType()

						// when input variable value must be nonNull, and set default value is unnecessary
						if ttype, ok := ttype.(*NonNull); ok && defaultValue != nil {
							reportError(
								context,
								fmt.Sprintf(`Variable "$%v" of type "%v" is required and will not use the default value. Perhaps you meant to use type "%v".`,
									name, ttype, ttype.OfType),
								[]ast.Node{defaultValue},
							)
						}
						if isValid, messages := isValidLiteralValue(ttype, defaultValue); !isValid && defaultValue != nil {
							if len(messages) > 0 {
								messagesStr = "\n" + strings.Join(messages, "\n")
							}
							reportError(
								context,
								fmt.Sprintf(`Variable "$%v" has invalid default value: %v.%v`,
									name, printer.Print(defaultValue), messagesStr),
								[]ast.Node{defaultValue},
							)
						}
					}
					return visitor.ActionSkip, nil
				},
			},
			kinds.SelectionSet: {
				Kind: func(p visitor.VisitFuncParams) (string, interface{}) {
					return visitor.ActionSkip, nil
				},
			},
			kinds.FragmentDefinition: {
				Kind: func(p visitor.VisitFuncParams) (string, interface{}) {
					return visitor.ActionSkip, nil
				},
			},
		},
	}
	return &ValidationRuleInstance{
		VisitorOpts: visitorOpts,
	}
}
120954
func (e Entry) Float32Default(key string, def float32) (float32, error) {
	v := e.ValueRaw
	if v == nil {
		return def, errFindParse.Format("float32", e.Key)
	}

	switch vv := v.(type) {
	case string:
		val, err := strconv.ParseFloat(vv, 32)
		if err != nil {
			return def, err
		}
		if val > math.MaxFloat32 {
			return def, errFindParse.Format("float32", e.Key)
		}
		return float32(val), nil
	case float32:
		return vv, nil
	case float64:
		if vv > math.MaxFloat32 {
			return def, errFindParse.Format("float32", e.Key)
		}
		return float32(vv), nil
	case int:
		return float32(vv), nil
	}

	return def, errFindParse.Format("float32", e.Key)
}
635652
func VerifyOptions(singular string, options []string, hasDefault bool) VerifyFunc {
	return func(s string) (ok bool, errmsg string, err error) {
		if s == "" {
			return hasDefault, "", nil
		}
		for _, opt := range options {
			if strings.ToLower(opt) == strings.ToLower(s) {
				return true, "", nil
			}
		}
		return false, fmt.Sprintf("Invalid %s: %q", singular, s), nil
	}
}
241758
func DefaultID(i interface{}) int {
	intVal, err := strconv.Atoi(fmt.Sprint(i))
	if err != nil {
		log.Fatalf(err.Error())
	}
	return intVal
}
421523
func (ca *CertAuthorityV2) CheckAndSetDefaults() error {
	err := ca.Metadata.CheckAndSetDefaults()
	if err != nil {
		return trace.Wrap(err)
	}

	err = ca.Check()
	if err != nil {
		return trace.Wrap(err)
	}

	return nil
}
949775
func (ctx *context) PostValueIntDefault(name string, def int) int {
	if v, err := ctx.PostValueInt(name); err == nil {
		return v
	}

	return def
}
730853
func (r *Store) GetDefault(key string, def interface{}) interface{} {
	v, ok := r.GetEntry(key)
	if !ok || v.ValueRaw == nil {
		return def
	}
	vv := v.Value()
	if vv == nil {
		return def
	}
	return vv
}
1041130
func (e Entry) IntDefault(def int) (int, error) {
	v := e.ValueRaw
	if v == nil {
		return def, fmt.Errorf(errFindParse, "int", e.Key)
	}
	if vint, ok := v.(int); ok {
		return vint, nil
	} else if vstring, sok := v.(string); sok && vstring != "" {
		vint, err := strconv.Atoi(vstring)
		if err != nil {
			return def, err
		}

		return vint, nil
	}

	return def, fmt.Errorf(errFindParse, "int", e.Key)
}
533839
func (a *APIMeta) GetVerifiablePasswordAuthentication() bool {
	if a == nil || a.VerifiablePasswordAuthentication == nil {
		return false
	}
	return *a.VerifiablePasswordAuthentication
}
676015
func (e Entry) Int64Default(def int64) (int64, error) {
	v := e.ValueRaw
	if v == nil {
		return def, fmt.Errorf(errFindParse, "int64", e.Key)
	}

	if vint64, ok := v.(int64); ok {
		return vint64, nil
	}

	if vint, ok := v.(int); ok {
		return int64(vint), nil
	}

	if vstring, sok := v.(string); sok {
		return strconv.ParseInt(vstring, 10, 64)
	}

	return def, fmt.Errorf(errFindParse, "int64", e.Key)
}
510020
func (r *Store) GetInt32Default(key string, def int32) int32 {
	if v, err := r.GetInt32(key); err == nil {
		return v
	}

	return def
}
914553
func (s *ServerV2) CheckAndSetDefaults() error {
	err := s.Metadata.CheckAndSetDefaults()
	if err != nil {
		return trace.Wrap(err)
	}

	return nil
}