rulii-bean-validation 1.0.0
rulii-bean-validation 1.0.0 is the first release of a new library, on rulii 2.2.0, the jakarta.validation API 3.1 and Java 17. It reads the jakarta.validation constraints on your beans and turns each one into a rulii rule: named, described, categorised under the bean class and tagged with its groups, visible in the trace and listable from the registry. To the rest of your code it is a Bean Validation provider: BeanValidator implements jakarta.validation.Validator, a validation returns Set<ConstraintViolation<T>>, and the standard bootstrap finds the provider through META-INF/services. A bean annotated for Hibernate Validator validates unchanged, with the same null semantics, paths and messages.
Why run validation on a rule engine
Section titled “Why run validation on a rule engine”Bean Validation stops at the annotation. A constraint checks one value; anything that looks at two fields, at the state of the system, or at who is asking means a ConstraintValidator class, a class-level annotation, and a place for logic the specification does not give you. This library keeps everything the annotations do and adds three things:
@Validateattaches a rule, rule set or rule flow from a ruliiRuleRegistryto a class, property, method or constructor, by name. What runs under that name can change at runtime without touching the bean.@Expris an inline cross-field condition in any scripting language rulii knows:@Expr(value = "#{end.isAfter(start)}", errorCode = "trip.end"). The language comes from the annotation, from@ExprDefaultson the class or package, or fromrulii.script.defaultLanguage; it is never guessed.@Bindparameterises one registered rule per declaration site, the waymax = 10parameterises@Size.
The line the library draws: annotations describe what is intrinsic to the data; rules decide what is contextual. The test for an @Expr is whether the condition would ever change for a business reason. If yes, it is a rule.
What is in the box
Section titled “What is in the box”All 22 built-in Jakarta constraints, groups and sequences, @ConvertGroup, cascading, container element constraints with value extractors, method and constructor validation, the metadata API and the default message interpolation. The constraints Hibernate Validator users know are there too, under org.rulii.validation.beans.constraints with the same names and attributes: @UUID, @ISBN, @EAN, @CreditCardNumber, @LuhnCheck, @Mod10Check, @Mod11Check, @UniqueElements, @Normalized, @CodePointLength, @Length, @Range, @URL, @DurationMin and @DurationMax, each backed by a rulii validator added in 2.2.0.
The library is not a certified implementation and does not run the TCK. The specification coverage page lists every known deviation, chapter by chapter, and the migration guide says what a project coming from Hibernate Validator will notice.
Spring Boot
Section titled “Spring Boot”rulii-spring 2.2.0 brings this library in and makes it the application’s Validator, wired into the Spring rulii context: @Validate names are bean names, constraint validators are Spring beans, and the provider is selected even with Hibernate Validator still on the classpath. The explorer 1.1.0 shows the validated beans and the rules behind every constraint.
Start with Validating Beans.