Skip to content

arasdenizhan/slim-validator

Repository files navigation

slim-validator

Build License Release Maven Central Java

A lightweight, annotation-driven Java validation library with zero dependencies.
Easily validate your POJOs using simple annotations like @NotNull, @Min, @Max, @Pattern, @Email, and @Length.

More features will be integrated soon.


🚀 Features

  • Annotation-based validation — simple and clear
  • Supported annotations:
    • @NotNull — null check
    • @Min / @Max — numeric boundaries
    • @Pattern — regex pattern validation
    • @Email — email format validation
    • @Length — string length constraints
    • @NotBlank — string null, empty and only whitespace check
    • @Past and @Future — date check
  • Performance optimized — reflection access is cached
  • Easy integration — just annotate your POJOs and call the validator
  • Open source — community-driven and extendable

💡 Usage

1. Define your POJO

public class UserDto {
    @NotNull(message = "Email cannot be null")
    @Email(message = "Email format is invalid")
    private String email;

    @Min(value = 18, message = "Age must be at least 18")
    @Max(value = 99, message = "Age must be less than 100")
    private Integer age;

    @Length(min = 2, max = 3, message = "Country code length must be between 2 and 3")
    private String countryCode;

    // getters and setters
}

2. Validate your object

SlimValidator validator = new SlimValidator();

UserDto userDto = new UserDto();
userDto.setAge(12);
userDto.setCountryCode("US");
userDto.setEmail("email@example.com");

validator.validate(userDto); // throws ValidationException on failure

📦 Central Repository

  • Maven (Latest Version)
<dependency>
  <groupId>io.github.arasdenizhan</groupId>
  <artifactId>slim-validator</artifactId>
  <version>1.2.0</version>
</dependency>
  • Gradle (Latest Version)
implementation group: 'io.github.arasdenizhan', name: 'slim-validator', version: '1.2.0'

🛠️ Development

  • Easily add new annotations and validation strategies
  • Extensible architecture based on StrategyFactory
  • Reflection caching for optimal performance

📚 Documentation

The full API documentation is available at:

👉 Javadoc for Slim Validator


📚 Benchmark Chart

chart


📄 License

Apache License 2.0 (Open source and free to use)


🤝 Contribution

Pull requests and issues are welcome!


Contact

Denizhan Aras — github.com/arasdenizhan

About

Lightweight annotation-based validation library for Java with zero dependencies.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages