Chisle
The coding-agent plugin that bills 52% of a bare model across 20 live tasks. Terse persona + tool-output compressor + context diet.
Yet Another Validation for Java (A lambda based type safe validation framework)
Translation pending
Developer toolsGitHub @makingOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
Repository information has not been collected yet.
No updates detected yet. GitHub releases will appear here.
The maker's introduction consists of the line above. Read the repository README for more details. Repository README ↗
Loading the full README.
Read the full README ↗YAVI (pronounced jɑ-vάɪ) is a lambda based type safe validation for Java.
YAVI sounds as same as a Japanese slang "YABAI (ヤバイ)" that means awesome or awful depending on the context (like "Crazy"). If you use YAVI, you will surely understand that it means the former.
The concepts are
If you are not a fan of Bean Validation, YAVI will be an awesome alternative.
YAVI has the following features:
See the reference documentation for details.
This content is derived from https://hibernate.org/validator/documentation/getting-started/
Welcome to YAVI.
The following paragraphs will guide you through the initial steps required to integrate YAVI into your application.
This guide uses the API of YAVI 0.18.0, which is not released yet. In order to use its snapshot within a Maven project, add the following dependency and repository to
your pom.xml:
<dependency>
<groupId>am.ik.yavi</groupId>
<artifactId>yavi</artifactId>
<version>0.18.0-SNAPSHOT</version>
</dependency>
<repositories>
<repository>
<id>central-snapshots</id>
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
The latest release is 0.17.3; see the reference documentation for its API.
This tutorial uses JUnit and AssertJ. Add the following dependencies as needed:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>6.1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.27.7</version>
<scope>test</scope>
</dependency>
YAVI validates in two styles. Choose by what you have in hand when validation starts:
| You have | You want | Use |
|---|---|---|
Input that is not an object yet: a Map, a parsed JSON document, request parameters | To validate it and then create the object, so that an invalid object never exists | Yavi.schema() ... fromMap(...) |
| An object that is already created, as with Bean Validation | The "classic" style: to check the object and get its violations | ValidatorBuilder |
Yavi.schema() describes the properties of an input, and fromMap ends it with a validator that reads them from a Map<String, Object> by their names, checks their types and gives them to a constructor. The object is created only when every property is valid.
Create src/main/java/com/example/Car.java and write the following code.
package com.example;
import am.ik.yavi.input.ObjectInputValidator;
import am.ik.yavi.validator.Yavi;
public record Car(String manufacturer, String licensePlate, Integer seatCount) {
public static final ObjectInputValidator<Car> validator = Yavi.schema()
._string("manufacturer")
._string("licensePlate", c -> c.greaterThanOrEqual(2).lessThanOrEqual(14))
._integer("seatCount", c -> c.greaterThanOrEqual(2))
.fromMap(Car::new);
}
Each method of the schema declares a property with its type, its name and its constraints:
manufacturer must be a stringlicensePlate must be a string that is between 2 and 14 characters longseatCount must be an integer that is at least 2A property is required: an absent key is reported with object.required ("manufacturer" is required) and null with object.notNull ("manufacturer" must not be null), so notNull() need not be written and the constructor is never given null. A property that may be null says so with nullable() or optional(), as described below.
To perform a validation, give a map to the validator. To demonstrate this, let’s have a look at a simple unit test:
Create src/test/java/com/example/CarTest.java and write the following code.
This is the beginning of the README. Read the rest at the original. Read the full README ↗