// internalValidSubset return a new Dataset containing only the rows validating their
// constraints or not depending on its parameter `valid`.
346683
func (d *Dataset) internalValidSubset(valid bool) *Dataset {
	if !d.HasAnyConstraint() {
		return d
	}

	nd := NewDataset(d.headers)
	nd.data = make([][]interface{}, 0)
	ndRowIndex := 0
	nd.tags = make([][]string, 0)

	for i, row := range d.data {
		keep := true
		for j, val := range d.data[i] {
			if d.constraints[j] != nil {
				switch val.(type) {
				case DynamicColumn:
					if valid {
						keep = d.constraints[j]((val.(DynamicColumn))(row))
					} else {
						keep = !d.constraints[j]((val.(DynamicColumn))(row))
					}
				default:
					if valid {
						keep = d.constraints[j](val)
					} else {
						keep = !d.constraints[j](val)
					}
				}
			}
			if valid && !keep {
				break
			}
		}
		if keep {
			nd.data = append(nd.data, make([]interface{}, 0, nd.cols))
			nd.data[ndRowIndex] = append(nd.data[ndRowIndex], row...)

			nd.tags = append(nd.tags, make([]string, 0, nd.cols))
			nd.tags[ndRowIndex] = append(nd.tags[ndRowIndex], d.tags[i]...)
			ndRowIndex++
		}
	}
	nd.cols = d.cols
	nd.rows = ndRowIndex

	return nd
}
408466
func internalLoadFromDict(input []map[string]interface{}) (*Dataset, error) {
	// retrieve columns
	headers := make([]string, 0, 10)
	for h := range input[0] {
		headers = append(headers, h)
	}

	ds := NewDataset(headers)
	for _, e := range input {
		row := make([]interface{}, 0, len(headers))
		for _, h := range headers {
			row = append(row, e[h])
		}
		ds.AppendValues(row...)
	}

	return ds, nil
}
408491
func (mc *multiProvider) ValidatorSet(chainID string, height int64) (valset *types.ValidatorSet, err error) {
	for _, p := range mc.providers {
		valset, err = p.ValidatorSet(chainID, height)
		if err == nil {
			// TODO Log unexpected types of errors.
			return valset, nil
		}
	}
	return nil, lerr.ErrUnknownValidators(chainID, height)
}
412965
func InternalErrorf(format string, params ...interface{}) error {
	return internal(fmt.Sprintf(format, params...))
}
986250
func (m *GormLabelRepository) IsValid(ctx context.Context, id uuid.UUID) bool {
	return repository.CheckExists(ctx, m.db, LabelTableName, id) == nil
}
4396
func (precondition *ScalePrecondition) ValidateReplicaSet(replicaSet *extensions.ReplicaSet) error {
	if precondition.Size != -1 && replicaSet.Spec.Replicas != precondition.Size {
		return PreconditionError{"replicas", strconv.Itoa(precondition.Size), strconv.Itoa(replicaSet.Spec.Replicas)}
	}
	if len(precondition.ResourceVersion) != 0 && replicaSet.ResourceVersion != precondition.ResourceVersion {
		return PreconditionError{"resource version", precondition.ResourceVersion, replicaSet.ResourceVersion}
	}
	return nil
}
1315141
func filterIsSubset(a, b []Filter) bool {
	if len(a) > len(b) {
		return false
	}
	var ib int
	for ia := range a {
		found := false
		for ; ib < len(b); ib++ {
			if a[ia].Field > b[ib].Field {
				// not same filter
				continue
			}
			if a[ia].Field < b[ib].Field {
				// field not in b
				return false
			}

			if a[ia].CompOp == b[ib].CompOp && a[ia].Value == b[ib].Value {
				found = true
				break
			}
			if filterContains(a[ia], b[ib]) {
				found = true
				break
			}
			return false
		}
		if !found {
			return false
		}
	}
	return true
}
480205
func ValidateStatefulSetStatusUpdate(statefulSet, oldStatefulSet *apps.StatefulSet) field.ErrorList {
	allErrs := field.ErrorList{}
	allErrs = append(allErrs, ValidateStatefulSetStatus(&statefulSet.Status, field.NewPath("status"))...)
	allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&statefulSet.ObjectMeta, &oldStatefulSet.ObjectMeta, field.NewPath("metadata"))...)
	// TODO: Validate status.
	if apivalidation.IsDecremented(statefulSet.Status.CollisionCount, oldStatefulSet.Status.CollisionCount) {
		value := int32(0)
		if statefulSet.Status.CollisionCount != nil {
			value = *statefulSet.Status.CollisionCount
		}
		allErrs = append(allErrs, field.Invalid(field.NewPath("status").Child("collisionCount"), value, "cannot be decremented"))
	}
	return allErrs
}
641729
func IsErrorNoRowsInResultSet(err error) bool {
	switch err {
	case nil:
		return false
	case sql.ErrNoRows:
		return true
	}
	if ErrorNoRowsInResultSet.Match(err) {
		return true
	}
	switch err.Error() {
	case "sql: no rows in result set", "no row affected":
		return true
	}
	return false
}
729767
func (s *LabelParameterVersionOutput) SetInvalidLabels(v []*string) *LabelParameterVersionOutput {
	s.InvalidLabels = v
	return s
}
1310654
func (statefulSetStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
	// TODO: Validate status updates.
	return validation.ValidateStatefulSetStatusUpdate(obj.(*apps.StatefulSet), old.(*apps.StatefulSet))
}
900942
func ValidateTableOptions(opts *metav1.TableOptions) field.ErrorList {
	var allErrs field.ErrorList
	switch opts.IncludeObject {
	case metav1.IncludeMetadata, metav1.IncludeNone, metav1.IncludeObject, "":
	default:
		allErrs = append(allErrs, field.Invalid(field.NewPath("includeObject"), opts.IncludeObject, "must be 'Metadata', 'Object', 'None', or empty"))
	}
	return allErrs
}
1187585
func (r inclusiveRules) IsValid(value string) bool {
	for _, rule := range r {
		if !rule.IsValid(value) {
			return false
		}
	}
	return true
}
685130
func IsInvalidType(err error) bool {
	_, ok := Cause(err).(InvalidTypeError)
	return ok
}
609349
func (k internalKey) valid() bool {
	i := len(k) - 8
	return i >= 0 && internalKeyKind(k[i]) <= internalKeyKindMax
}
74493
func (policy Policy) isValid() error {
	if policy.Version != DefaultVersion && policy.Version != "" {
		return fmt.Errorf("invalid version '%v'", policy.Version)
	}

	for _, statement := range policy.Statements {
		if err := statement.isValid(); err != nil {
			return err
		}
	}

	for i := range policy.Statements {
		for _, statement := range policy.Statements[i+1:] {
			principals := policy.Statements[i].Principal.Intersection(statement.Principal)
			if principals.IsEmpty() {
				continue
			}

			actions := policy.Statements[i].Actions.Intersection(statement.Actions)
			if len(actions) == 0 {
				continue
			}

			resources := policy.Statements[i].Resources.Intersection(statement.Resources)
			if len(resources) == 0 {
				continue
			}

			if policy.Statements[i].Conditions.String() != statement.Conditions.String() {
				continue
			}

			return fmt.Errorf("duplicate principal %v, actions %v, resouces %v found in statements %v, %v",
				principals, actions, resources, policy.Statements[i], statement)
		}
	}

	return nil
}
468921
func (c *timeSeriesConfCache) IsValid() bool {
	return c.TimeSeriesConfs != nil && time.Since(c.Generated) < c.TTL
}