// Normalize normalizes the JSONObject (ensures it's an object, removes
// whitespace, sorts keys, normalizes Size value, etc.)
965641
func (j *JsonResult) Normalize() error {
	if j == nil {
		return nil
	}
	if j.Object == "" {
		j.Size = 0
		return nil
	}
	if len(j.Object) > jsonNonNormalizedSize {
		return fmt.Errorf(
			"JSONObject.Object length exceeds max non-normalized length: %d > %d (max)",
			len(j.Object), jsonNonNormalizedSize)
	}
	normed, err := template.NormalizeJSON(j.Object, true)
	if err != nil {
		return err
	}
	if len(normed) > JSONObjectMaxLength {
		return fmt.Errorf(
			"JSONObject.Object length exceeds max: %d > %d (max)",
			len(normed), JSONObjectMaxLength)
	}
	j.Object = normed
	j.Size = uint32(len(j.Object))
	return nil
}
924507
func (d *Dependency) Normalize() error {
	if d.Shards == 0 {
		d.Shards = 1
	}
	if err := d.GetAttempts().Normalize(); err != nil {
		return err
	}
	return d.Phrase.Normalize()
}
830541
func (s *GraphQuery_Search) Normalize() error {
	// for now, start and end MUST be timestamp values.
	switch s.Start.Value.(type) {
	case *PropertyValue_Time:
	default:
		return fmt.Errorf("invalid Start type: %T", s.Start.Value)
	}
	switch s.End.Value.(type) {
	case *PropertyValue_Time:
	default:
		return fmt.Errorf("invalid End type: %T", s.End.Value)
	}
	return nil
}
366549
func (a *Execution_Auth) Normalize() error {
	if a == nil {
		return errors.New("Execution_Auth is nil")
	}
	if a.Id == nil {
		return errors.New("Execution_Auth.Id is nil")
	}
	return nil
}
1209009
func (s *Config_Swarming) Normalize() (err error) {
	if err = schemaHostURLValidate(s.Url); err != nil {
		return fmt.Errorf("config.swarming.host: %s", err)
	}
	return
}
81335
func (q1 Quat) Normalize() Quat {
	length := q1.Len()

	if FloatEqual(1, length) {
		return q1
	}
	if length == 0 {
		return QuatIdent()
	}
	if length == InfPos {
		length = MaxValue
	}

	return Quat{q1.W * 1 / length, q1.V.Mul(1 / length)}
}
81711
func (s *stateV4) normalize() {
	sort.Stable(sortResourcesV4(s.Resources))
	for _, rs := range s.Resources {
		sort.Stable(sortInstancesV4(rs.Instances))
	}
}
869003
func (as *AnnotationStream) Normalize() error {
	if err := as.Project.Validate(); err != nil {
		return errors.Annotate(err, "Invalid project name: %s", as.Project).Tag(grpcutil.InvalidArgumentTag).Err()
	}

	if err := as.Path.Validate(); err != nil {
		return errors.Annotate(err, "Invalid log stream path %q", as.Path).Tag(grpcutil.InvalidArgumentTag).Err()
	}

	return nil
}
1115788
func (i *Config_Isolate) Normalize() (err error) {
	if err = schemaHostURLValidate(i.Url); err != nil {
		return fmt.Errorf("config.isolate.host: %s", err)
	}
	return
}
781399
func normalize(v reflect.Value) interface{} {
	k := v.Kind()

	switch {
	case isNumber(k):
		f, err := numberToFloat(v)
		if err == nil {
			return f
		}
	}

	return v.Interface()
}
614516
func (v Vector) Normalize() Vector {
	if v == (Vector{0, 0, 0}) {
		return v
	}
	return v.Mul(1 / v.Norm())
}
1093702
func (v Vector) Normalize() Vector {
	n2 := v.Norm2()
	if n2 == 0 {
		return Vector{0, 0, 0}
	}
	return v.Mul(1 / math.Sqrt(n2))
}
1146780
func (config *BitriseDataModel) Normalize() error {
	if err := config.App.Normalize(); err != nil {
		return err
	}

	for _, workflow := range config.Workflows {
		if err := workflow.Normalize(); err != nil {
			return err
		}
	}

	return nil
}
1225876
func (env *EnvironmentItemModel) Normalize() error {
	opts, err := env.GetOptions()
	if err != nil {
		return err
	}
	(*env)[OptionsKey] = opts
	return nil
}
535382
func (a *ActivateExecutionReq) Normalize() error {
	if err := a.Auth.Normalize(); err != nil {
		return err
	}
	if len(a.ExecutionToken) < MinimumActivationTokenLength {
		return fmt.Errorf("insufficiently long ExecutionToken: %d",
			len(a.ExecutionToken))
	}
	return nil
}
1288222
func (j *Parameters_Job) Normalize() (err error) {
	if err = j.Inputs.Normalize(); err != nil {
		return
	}
	if len(j.Command) == 0 {
		return errors.New("job.command: command is required")
	}
	for k := range j.Env {
		if k == "" {
			return errors.New("job.env: environment key is empty")
		}
	}
	return
}
856695
func (p *Parameters) Normalize() (err error) {
	if err = p.Scheduling.Normalize(); err != nil {
		return
	}
	if err = p.Meta.Normalize(); err != nil {
		return
	}
	if err = p.Job.Normalize(); err != nil {
		return
	}
	return
}