// ValidateChange returns a CustomizeDiffFunc that applies the given validation
// function to the change for the given key, returning any error produced.
179951
func ValidateChange(key string, f ValueChangeValidationFunc) schema.CustomizeDiffFunc {
	return func(d *schema.ResourceDiff, meta interface{}) error {
		old, new := d.GetChange(key)
		return f(old, new, meta)
	}
}
223495
func (strategy) ValidateUpdate(ctx context.Context, obj runtime.Object, old runtime.Object) field.ErrorList {
	return nil
}
328903
func (m *DurationFilter) Validate() error {
	if m == nil {
		return nil
	}

	if m.GetComparison() == nil {
		return DurationFilterValidationError{
			field:  "Comparison",
			reason: "value is required",
		}
	}

	{
		tmp := m.GetComparison()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return DurationFilterValidationError{
					field:  "Comparison",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	return nil
}
136367
func (filter *Filter) Validate() error {
	if filter.EventFormat != "client" && filter.EventFormat != "federation" {
		return errors.New("Bad event_format value. Must be one of [\"client\", \"federation\"]")
	}
	return nil
}
1016848
func (key AnnotationKey) Validate(_ interface{}) error {
	if annotationKeyRegex.Match([]byte(key)) {
		return nil
	}

	return errInvalidAnnotationKey
}
1068096
func (fbo *folderBlockOps) GetInvalidationChangesForNode(
	ctx context.Context, lState *kbfssync.LockState, node Node) (
	changes []NodeChange, affectedNodeIDs []NodeID, err error) {
	if fbo.nodeCache == nil {
		// Nothing needs to be done!
		return nil, nil, nil
	}

	fbo.blockLock.Lock(lState)
	defer fbo.blockLock.Unlock(lState)
	fbo.vlog.CLogf(
		ctx, libkb.VLog1, "About to get all children for node %p", node)
	childNodes := fbo.nodeCache.AllNodeChildren(node)
	fbo.vlog.CLogf(
		ctx, libkb.VLog1, "Found %d children for node %p", len(childNodes),
		node)
	return fbo.getInvalidationChangesForNodes(
		ctx, lState, append(childNodes, node))
}
157414
func (constraints *tokenConstraints) validate() (err error) {
	keys := 0
	if constraints.key != nil {
		keys++
	}
	if constraints.secret != "" {
		keys++
	}
	if keys > 1 {
		err = fmt.Errorf("duplicate key constraints")
		return
	}
	if keys < 1 {
		err = fmt.Errorf("no key constraint")
		return
	}
	return
}
94352
func (m *StatusCodeFilter) Validate() error {
	if m == nil {
		return nil
	}

	if m.GetComparison() == nil {
		return StatusCodeFilterValidationError{
			field:  "Comparison",
			reason: "value is required",
		}
	}

	{
		tmp := m.GetComparison()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return StatusCodeFilterValidationError{
					field:  "Comparison",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	return nil
}
261419
func (lobby *Lobby) OnChange(base bool) {
	switch lobby.State {
	case Waiting, InProgress, ReadyingUp:
		BroadcastLobby(lobby)
		if base {
			BroadcastLobbyList()
		}
	}
}
1224493
func (f *FloatRule) Validate(cv ctypes.ConfigValue) error {
	// Check that type is correct
	if cv.Type() != FloatType {
		return wrongType(f.key, cv.Type(), FloatType)
	}
	// Check minimum. Type should be safe now because of the check above.
	if f.minimum != nil && cv.(ctypes.ConfigValueFloat).Value < *f.minimum {
		return errors.New(fmt.Sprintf("value is under minimum (%s value %f < %f)", f.key, cv.(ctypes.ConfigValueFloat).Value, *f.minimum))
	}
	// Check maximum. Type should be safe now because of the check above.
	if f.maximum != nil && cv.(ctypes.ConfigValueFloat).Value > *f.maximum {
		return errors.New(fmt.Sprintf("value is over maximum (%s value %f > %f)", f.key, cv.(ctypes.ConfigValueFloat).Value, *f.maximum))
	}
	return nil
}
131673
func (cs *CachableSource) HandleChange(kind fsutil.ChangeKind, p string, fi os.FileInfo, err error) (retErr error) {
	cs.mu.Lock()
	if cs.txn == nil {
		cs.txn = cs.tree.Txn()
	}
	if kind == fsutil.ChangeKindDelete {
		cs.txn.Delete([]byte(p))
		cs.mu.Unlock()
		return
	}

	h, ok := fi.(hashed)
	if !ok {
		cs.mu.Unlock()
		return errors.Errorf("invalid fileinfo: %s", p)
	}

	hfi := &fileInfo{
		sum: h.Digest().Hex(),
	}
	cs.txn.Insert([]byte(p), hfi)
	cs.mu.Unlock()
	return nil
}
155458
func RequireKeyUnchanged(key string) PreconditionFunc {
	return func(diff interface{}) bool {
		m, ok := diff.(map[string]interface{})
		if !ok {
			return true
		}
		// the presence of key in a diff means that its value has been changed, therefore
		// we should fail the precondition.
		_, ok = m[key]
		return !ok
	}
}
1091190
func (s *ChangesService) RevertChange(changeID string, input *RevertInput) (*ChangeInfo, *Response, error) {
	return s.change("revert", changeID, input)
}
230956
func ValidateRange(ch *Changeset, field string, min int, max int, opts ...Option) {
	val, exist := ch.changes[field]
	if !exist {
		return
	}

	options := Options{
		message: ValidateRangeErrorMessage,
	}
	options.apply(opts)

	invalid := false

	switch v := val.(type) {
	case string:
		invalid = len(v) < min || len(v) > max
	case []interface{}:
		invalid = len(v) < min || len(v) > max
	case int:
		invalid = v < min || v > max
	case int8:
		invalid = v < int8(min) || v > int8(max)
	case int16:
		invalid = v < int16(min) || v > int16(max)
	case int32:
		invalid = v < int32(min) || v > int32(max)
	case int64:
		invalid = v < int64(min) || v > int64(max)
	case uint:
		invalid = v < uint(min) || v > uint(max)
	case uint8:
		invalid = v < uint8(min) || v > uint8(max)
	case uint16:
		invalid = v < uint16(min) || v > uint16(max)
	case uint32:
		invalid = v < uint32(min) || v > uint32(max)
	case uint64:
		invalid = v < uint64(min) || v > uint64(max)
	case uintptr:
		invalid = v < uintptr(min) || v > uintptr(max)
	case float32:
		invalid = v < float32(min) || v > float32(max)
	case float64:
		invalid = v < float64(min) || v > float64(max)
	}

	if invalid {
		r := strings.NewReplacer("{field}", field, "{min}", strconv.Itoa(min), "{max}", strconv.Itoa(max))
		AddError(ch, field, r.Replace(options.message))
	}
}
1049543
func (fbo *folderBlockOps) GetInvalidationChangesForAll(
	ctx context.Context, lState *kbfssync.LockState) (
	changes []NodeChange, affectedNodeIDs []NodeID, err error) {
	if fbo.nodeCache == nil {
		// Nothing needs to be done!
		return nil, nil, nil
	}

	fbo.blockLock.Lock(lState)
	defer fbo.blockLock.Unlock(lState)
	childNodes := fbo.nodeCache.AllNodes()
	fbo.vlog.CLogf(ctx, libkb.VLog1, "Found %d nodes", len(childNodes))
	return fbo.getInvalidationChangesForNodes(ctx, lState, childNodes)
}
262504
func (s *StringCodeGenerator) ToolChange(t int) {
	if s.Tool == t {
		if s.Lines[len(s.Lines)-1] == fmt.Sprintf("T%d", t) {
			s.Lines[len(s.Lines)-1] = fmt.Sprintf("M6 T%d", t)
		} else {
			s.put("M6")
		}
	} else {
		s.put(fmt.Sprintf("M6 T%d", t))
		s.Tool = t
	}
	s.ForceModeWrite = true
}
1127483
func (m *EndpointChangeRequest) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}