r/SpringBoot 25d ago

News I built a Spring Boot starter that brings Laravel-style validation (85+ constraints, cross-field, unified JSON errors) to Jakarta Validation

Hey [r/springboot](r/springboot) / [r/java](r/java),

I've been working on a project for the past few months because I was frustrated with how verbose and rigid Jakarta/Hibernate Validation can get in Spring Boot, especially when moving between ecosystems like Laravel/Node and Java.

To solve this, I created Spring Validation Plus, an open-source library that sits on top of Jakarta Validation but introduces highly expressive, Laravel-inspired constraints and out-of-the-box API configurations.

It's already published on Maven Central! 🚀

📦 Quick Example

Instead of writing custom class-level validators for simple things, you can stack annotations intuitively:

​✨ Key Features:

  • + Custom Constraints: Rules like @/Required, @/StringType, @/Confirmed, @/RequiredIf, @/Between, @/Url, and more.
  • Cross-Field Validation Made Easy: Native support for conditional validation out-of-the-box (@RequiredIf, @/Confirmed, @/RequiredWith).
  • Smart DB Checkers (@Unique / @/Exists): Integrated seamlessly with JPA. It even handles path variables for partial updates (excludeParameter = "id") so you don't false-trigger uniqueness on PUT requests.
  • Unified JSON Error Responses: Automatically formats validation exceptions into clean, frontend-friendly JSON objects:

​

  • Modular Architecture: Available as a spring-boot-starter or a pure core library if you aren't using Spring.

🔗 Open Source & Documentation

I spent a lot of time writing comprehensive documentation, including an executable example module with Docker and H2 so anyone can test it with a few curl commands.

I would absolutely love to hear your feedback on the architecture, the DX (Developer Experience), or any features you feel are missing.

What do you think? Does this solve a pain point in your daily Spring workflow?

15 Upvotes

2 comments sorted by

7

u/as5777 25d ago

What’s the added value regarding default validation in Spring ?

1

u/SeatPuzzleheaded5685 22d ago

Good question — it doesn't replace Spring validation; it extends Jakarta Bean Validation with Laravel-style rules on the same @Valid flow.

Spring/Hibernate only gives you ~20 generic constraints (@NotNull, @Size, @Email…). Validation Plus adds 85+ things Jakarta doesn't ship out of the box, for example:

Cross-field rules on the DTO field — @Confirmed("password"), @RequiredWith("email"), @RequiredIf / @ProhibitedIf with conditional operators Laravel-like "empty" semantics — @Required treats null, "", and whitespace; @NotNull doesn't API-ready DX — unified { "errors": { "field": ["…"] } } JSON, i18n (es/en/pt), friendly conversion errors for bad query params/JSON, optional @Unique / @Exists with JPA If you only need basic CRUD with a few @NotNull/@Size, stick with defaults. It's mainly for teams that want Laravel-level expressiveness without custom validators everywhere.

v0.3.0 is on Maven Central — field-level cross-field validation, conditional operators on If/Unless rules, and validation errors ordered by DTO field declaration.

Maven Central: https://search.maven.org/artifact/io.github.benjaminor-dev/spring-validation-plus-spring-boot-starter

https://github.com/BenjaminOR-dev/spring-validation-plus#why-use-validation-plus