Skip to content
Malio
Open Source · Java 11 · GWT · J2CL

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.

Apache 2.0   /   Annotation processor   /   GWT & J2CL compatible   /   English and German messages
Mongoose with a magnifying glass and a checkmark
@NotNull@MaxLength@Email@Regexp@Sizecheck()validate()
Annotate. Generate. Validate.

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.

Annotate & checkJava
// 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 →

Source and issues

Contribute, report a problem or look at the tests for examples.

View on GitHub ↗