// Return a RequiredNotSetError indicating which required field was not set.
766361
func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError {
	st := sv.Type()
	sprops := GetProperties(st)
	for i := 0; i < st.NumField(); i++ {
		if !isNil(sv.Field(i)) {
			continue
		}

		props := sprops.Prop[i]
		if props.Required {
			return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)}
		}
	}
	return &RequiredNotSetError{fmt.Sprintf("%v.<unknown field name>", st)} // should not happen
}
227298
func isRequired(field *descriptor.FieldDescriptorProto) bool {
	return field.Label != nil && *field.Label == descriptor.FieldDescriptorProto_LABEL_REQUIRED
}
1189565
func ReqError(f reflect.StructField, actual interface{}) error {
	return fmt.Errorf("%s: required, actual `%v`", f.Name, actual)
}
711271
func (r fieldRequiredness) isRequired(src *ast.Field) (bool, error) {
	switch r {
	case explicitRequiredness:
		if src.Requiredness == ast.Unspecified {
			return false, requirednessRequiredError{
				FieldName: src.Name,
				Line:      src.Line,
			}
		}
	case noRequiredFields:
		if src.Requiredness == ast.Required {
			return false, cannotBeRequiredError{
				FieldName: src.Name,
				Line:      src.Line,
			}
		}
	default:
		// do nothing
	}

	// A field is considered required only if it was marked required AND it
	// does not have a default value.
	return (src.Requiredness == ast.Required && src.Default == nil), nil
}
1167265
func NewInvalidError(field *FieldPath, value interface{}, detail string) *Error {
	return &Error{ErrorTypeInvalid, field.String(), value, detail}
}
237142
func ValidateStatefulSetUpdate(statefulSet, oldStatefulSet *apps.StatefulSet) field.ErrorList {
	allErrs := apivalidation.ValidateObjectMetaUpdate(&statefulSet.ObjectMeta, &oldStatefulSet.ObjectMeta, field.NewPath("metadata"))

	restoreReplicas := statefulSet.Spec.Replicas
	statefulSet.Spec.Replicas = oldStatefulSet.Spec.Replicas

	restoreTemplate := statefulSet.Spec.Template
	statefulSet.Spec.Template = oldStatefulSet.Spec.Template

	restoreStrategy := statefulSet.Spec.UpdateStrategy
	statefulSet.Spec.UpdateStrategy = oldStatefulSet.Spec.UpdateStrategy

	if !apiequality.Semantic.DeepEqual(statefulSet.Spec, oldStatefulSet.Spec) {
		allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden"))
	}
	statefulSet.Spec.Replicas = restoreReplicas
	statefulSet.Spec.Template = restoreTemplate
	statefulSet.Spec.UpdateStrategy = restoreStrategy

	allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(statefulSet.Spec.Replicas), field.NewPath("spec", "replicas"))...)
	return allErrs
}
1006309
func Required(field *Path, detail string) *Error {
	return &Error{ErrorTypeRequired, field.String(), "", detail}
}
111463
func Required() Predicate {
	return PredicateFunc(func(param string, r *http.Request) error {
		if r.Form.Get(param) == "" {
			return &MissingParameterError{Param: param}
		}
		return nil
	})
}
280429
func (r *Response) SetError(id string, description string) {
	r.SetErrorUri(id, description, "", "")
}
495581
func validateRequired(v interface{}, name string) error {
	if v == nil {
		return ErrRequired
	}
	return validateNonEmpty(v, name)
}
1110263
func ReqFactory(e *ReqErrorOption) ValidationFunc {
	if e == nil {
		e = &ReqErrorOption{}
	}
	if e.UnsupportedTypeErrorOption == nil {
		e.UnsupportedTypeErrorOption = &UnsupportedTypeErrorOption{UnsupportedTypeError}
	}
	if e.ReqError == nil {
		e.ReqError = ReqError
	}
	return func(t *Target, param string) error {
		v := t.FieldValue

		switch v.Kind() {
		case reflect.String:
			if v.String() == "" {
				return e.ReqError(t.FieldInfo, v.String())
			}
		case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
			if v.Int() == 0 {
				return e.ReqError(t.FieldInfo, fmt.Sprintf("%d", v.Int()))
			}
		case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
			if v.Uint() == 0 {
				return e.ReqError(t.FieldInfo, fmt.Sprintf("%d", v.Uint()))
			}
		case reflect.Float32, reflect.Float64:
			if v.Float() == 0 {
				return e.ReqError(t.FieldInfo, fmt.Sprintf("%f", v.Float()))
			}
		case reflect.Bool:
		// :)

		case reflect.Array, reflect.Slice:
			if v.Len() == 0 {
				return e.ReqError(t.FieldInfo, v.Len())
			}
		case reflect.Struct:
			// t.FieldValue is de-referenced
			ofv := t.StructValue.Field(t.FieldIndex)
			if ofv.Kind() == reflect.Ptr && ofv.IsNil() {
				return e.ReqError(t.FieldInfo, "nil")
			}
		default:
			return e.UnsupportedTypeError("req", t.FieldInfo)
		}
		return nil
	}
}
956419
func MissingParamError(name string) error {
	msg := fmt.Sprintf("missing required parameter %#v", name)
	return ErrInvalidRequest(msg, "name", name)
}
442551
func NewMissingConfigValue(key, field string) error {
	return NewInvalidConfigValueError(key, "", errors.New("missing "+field))
}
553350
func IsNotRegisteredError(err error) bool {
	if err == nil {
		return false
	}
	_, ok := err.(*notRegisteredErr)
	return ok
}
1212541
func (o Option) RequiresOption(name string) bool {
	for _, o := range o.Requires {
		if o == name {
			return true
		}
	}

	return false
}
794654
func (r Resource) Required() string {
	required := []string{}

	for name, property := range r.Properties {
		if property.Required {
			required = append(required, `"`+name+`"`)
		}
	}

	// As Go doesn't provide ordering guarentees for maps, we should
	// sort the required property names by alphabetical order so that
	// they don't shuffle on every generation, and cause annoying commit diffs
	sort.Strings(required)

	return strings.Join(required, ", ")
}
165510
func PropertyNotAllowed(name, in, key string) *Validation {
	msg := fmt.Sprintf(unallowedProperty, name, key, in)
	if in == "" {
		msg = fmt.Sprintf(unallowedPropertyNoIn, name, key)
	}
	return &Validation{
		code:    UnallowedPropertyCode,
		Name:    name,
		In:      in,
		Value:   key,
		message: msg,
	}
}