Clear rules.
Reliable data.
Generated validators.
Add annotations to the fields of a POJO. At compile time, Malio generates the validator. Use it to check an object and stop at the first error, or to validate it and collect all error messages.
No validators to write.
More Java.
Constraints live next to the data they protect. Malio generates one validator per annotated class and calls the validators of nested types for you.
// Triggers the generation of PersonMalioValidator @MalioValidator public class Person { @NotNull @NotBlank @MaxLength(20) private String name; @NotNull private Address address; } // Throws on the first violation PersonMalioValidator.INSTANCE.check(person);
Annotations only
Put constraints on fields and add @MalioValidator to the class. There is nothing else to write.
Check or validate
check throws an exception at the first error. validate collects every error in a validation result.
Nested objects
If the type of a field has a Malio validator, it is called as well. @MalioIgnore breaks circular validations.
Inheritance
Validators of user-defined super classes are found and applied, and abstract classes can carry the annotation too.
Localized messages
Predefined messages in English and German. Replace the message of any single constraint with your own text.
Java, GWT and J2CL
Validate shared classes on the server and in the browser with the same annotations.
Start with a working example
Dependencies, a first annotated class and the first validation.
Read the quickstart →Know every constraint
All annotations with parameters, supported types, results and messages.
Open the API reference →