Rules
Default
Fill missing values with a fallback.
Use defaultValue(...) to write a fallback value when a field is missing.
Teki schema = Teki.fromRules(
string("role").defaultValue("user"),
number("retries").defaultValue(0)
);
schema.validate(request);After validation, Teki writes the default value back to the validated object when needed.
defaultValue triggers on null and on blank strings. It does not replace numeric zero — 0 is treated as a valid value.
Available on
string(...)number(...)
Annotation equivalent
import dev.ditsche.teki.annotation.Default;
public class SearchRequest {
@Default("25")
private Integer limit;
}The annotation scanner converts defaults for common primitive and wrapper types, including int, long, double, float, and boolean.