Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zoda-validation

A lightweight approach for a simple validation library for Java to validate complex objects with a fluent API.


Features

Fluent API – Reads like natural language
Type-safe – Leverages Java's type system with generics
Fail-slow – Collects all errors, not just the first one
Dynamic – Build validations at runtime; no annotations required
Extensible – Add custom validation logic with lambdas
Zero runtime dependencies – Lightweight library for production use


Installation

Add the following dependency to your pom.xml:

<dependency>
    <groupId>de.hofmann-hbm.zoda</groupId>
    <artifactId>zoda-validation</artifactId>
    <version>0.1.0-SNAPSHOT</version>
</dependency>

Quick Start

import de.hofmannhbm.zoda.Validator;
import de.hofmannhbm.zoda.ValidationResult;

ValidationResult result = Validator.of(user)
    .check(User::getName, "Name")
        .isNotNull()
        .matches(n -> n.length() > 3, "must be longer than 3 characters")
    .and()
    .check(User::getAge, "Age")
        .matches(age -> age >= 18, "must be at least 18")
    .and()
    .validate();

if (!result.isValid()) {
    result.getErrors().forEach(e ->
        System.out.println(e.fieldName() + ": " + e.message())
    );
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages