func()

in internal/azure/types/integer_type.go [22:48]


func (t *IntegerType) Validate(body interface{}, path string) []error {
	if body == nil {
		return nil
	}
	var v int
	switch input := body.(type) {
	case float64, float32:
		// TODO: skip validation for now because of the following issue:
		// the bicep-types-az parses float as integer type and it should be fixed: https://github.com/Azure/bicep-types-az/issues/1404
		return nil
	case int64:
		v = int(input)
	case int32:
		v = int(input)
	case int:
		v = input
	default:
		return []error{utils.ErrorMismatch(path, "integer", fmt.Sprintf("%T", body))}
	}
	if t.MinValue != nil && v < *t.MinValue {
		return []error{utils.ErrorCommon(path, fmt.Sprintf("value is less than %d", *t.MinValue))}
	}
	if t.MaxValue != nil && v > *t.MaxValue {
		return []error{utils.ErrorCommon(path, fmt.Sprintf("value is greater than %d", *t.MaxValue))}
	}
	return nil
}