JSR-303 (Bean Validation) is the Java specification that defines a metadata model and API for declaring and enforcing validation constraints on JavaBeans using annotations, so rules like "not null" or "matches this pattern" live on the field rather than in hand-written checks.
JSR-303
JSR-303, known as Bean Validation, is the Java specification that defines a metadata model and API for declaring and enforcing validation constraints on JavaBean objects using annotations. Introduced in 2009 and carried forward through JSR-349 and today’s Jakarta Bean Validation, it lets developers annotate fields with constraints like @NotNull, @Size, and @Pattern instead of hand-writing validation logic scattered through the codebase.
- Annotation-driven constraints -
@NotNull,@Min,@Max,@Size, and@Patterndeclared directly on the bean field. - Reference implementation - Hibernate Validator is the canonical implementation of the specification.
- Custom constraints - Define your own annotations and validators for domain-specific rules.
- Framework integration - Wired throughout Spring and Jakarta EE to validate request payloads automatically.
In API operations JSR-303 is where server-side request validation usually lives in a Java stack — a controller binds an incoming JSON body to an annotated bean, and the framework rejects anything that violates the constraints before business logic ever runs. Those same annotations increasingly double as documentation, since tooling can read them to generate schema constraints, helping keep the OpenAPI contract and the code’s actually-enforced rules in sync.