Session

Customized Jakarta Bean Validators

Most of use use annotations from Jakarta Bean Validations to define acceptable values for properties and parameters: @NotNull, @NotBlank, @Min, @Mix, @Size. Less code, more consistency, fewer bugs. Wonderful!

However, what about less-than-trivial object validations, e.g., validation based on object state or multiple properties? More complex validations require implementing custom validations which, if not careful, may become spaghetti code. However, there are alternatives, such as creating DSL (domain-specific language) validators.

If this problem sounds familiar, join me and learn how to create customized bean validators and how a DSL customized validator eliminates code bloat, resulting in maintainable and self-documenting validations. Hopefully you walk away with new ideas and possible approaches for your current dilemma!

The DSL validator is a real-life solution created to solve the problem of a customized validator whose code was impossible to understand. I've written up a 4-part DZone article discussing the specifics: https://dzone.com/articles/dsl-validations-properties

The DSL is Kotlin-based and publicly available on GItHub. The talk itself will be Java-based.

Scott Sosna

Independent Consultant

Saint Paul, Minnesota, United States

Actions

Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.

Jump to top