ent/ent · error
value out of range
Error message
value out of range
What it means
Runtime validation error returned by the Range validator attached to an integer field via schema/field.Int().Range(i, j): the value being checked falls outside the inclusive bounds [i, j] that the validator closure captured when the schema was defined. It fires at mutation time (or whenever the validator runs), naming the out-of-bounds integer, not the schema definition itself.
Source
Thrown at schema/field/numeric.go:130
}}
}
// intBuilder is the builder for int field.
type intBuilder struct {
desc *Descriptor
}
// Unique makes the field unique within all vertices of this type.
func (b *intBuilder) Unique() *intBuilder {
b.desc.Unique = true
return b
}
// Range adds a range validator for this field where the given value needs to be in the range of [i, j].
func (b *intBuilder) Range(i, j int) *intBuilder {
b.desc.Validators = append(b.desc.Validators, func(v int) error {
if v < i || v > j {
return errors.New("value out of range")
}
return nil
})
return b
}
// Min adds a minimum value validator for this field. Operation fails if the validator fails.
func (b *intBuilder) Min(i int) *intBuilder {
b.desc.Validators = append(b.desc.Validators, func(v int) error {
if v < i {
return errors.New("value out of range")
}
return nil
})
return b
}
// Max adds a maximum value validator for this field. Operation fails if the validator fails.View on GitHub (pinned to 69d5d4deb1)
Solutions
- Inspect the value that failed and compare it against the Range(i, j) bounds declared on the field in the ent schema
- Clamp or reject the input before it reaches the mutation, e.g. validate user input at the API layer using the same bounds
- If the bounds are wrong, widen them in the schema definition (e.g. field.Int("age").Range(0, 130)) — note validators are only enforced at runtime, codegen does not apply them
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at schema/field/numeric.go:130 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ent/ent@69d5d4deb1 (2026-09-03).
Data as JSON: /api/errors/79b0c454e74c9f79.
Report an issue: GitHub.