jakartaee / jakartaee/validation-spec
Enforce constraint validators to support injection if CDI is available
- Dominant language
- Java
- Stars
- 23
- Forks
- 22
- PR merge metrics
- No merged PRs in 30d
Description
I thought this was actually enforced in the spec since a long time, but it turns out it's not:
If CDI is supported in the container, it would be a benefit for developers if they could rely that an implementation also supports dependency injection in the validator.
https://beanvalidation.org/2.0/spec/#integration-dependencyinjection enforces this only that the validator must be injectable itself, but not "inside". Additionally the scope then should be handled by CDI, if a CDI scoped annotation is present.
**Example**
```java
@ApplicationScoped
public class OrderValidator implements ConstraintValidator {
@Inject
CoffeeShop coffeeShop;
// ...
```
Most impls IMO do this already, but it turns out not all (e.g. Payara), since it's not enforced in the spec. WDYT?
Contributor guide
Research direction
Read the linked Bean Validation 2.0 integration and dependency-injection section first. Compare its requirement that the validator itself be injectable with the requested behavior for injected fields and CDI scopes, then determine whether that behavior should become normative. Done means the proposed requirement has been resolved in the specification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, documentation
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100