Package dev.relism.flash.ext.validation
Class Validation
java.lang.Object
dev.relism.flash.ext.validation.Validation
The validation service. Resolve it with
require(Validation.class).
CreateUser dto = validation.body(req, CreateUser.class); // parse + verify
Constraints are compiled the first time a type is seen and cached in a ClassValue,
which the JVM stores beside the class itself — no map lookup, no lock, and the entry is
collected with the class rather than pinning it. Every later request walks the compiled table.
-
Method Summary
Modifier and TypeMethodDescription<T> TDeserializes the request body intotypeand verifies its constraints.The compiled constraints oftype.<T> Tvalidate(T value) Verifies an already-constructed value.
-
Method Details
-
body
Deserializes the request body intotypeand verifies its constraints.- Throws:
dev.relism.flash.exceptions.HttpException- 400 if the body is not valid JSONValidationException- 422 if it parses but violates a constraintException
-
validate
public <T> T validate(T value) Verifies an already-constructed value.- Returns:
value, so it can be used inline- Throws:
ValidationException- 422 on the first type's worth of failures
-
forType
The compiled constraints oftype. Useful to pre-warm a hot DTO at boot, or to check whether a type declares constraints at all.
-