fix: enhance global key validation and update template parameters

This commit is contained in:
Relism
2026-04-29 10:31:14 +02:00
parent 0e2dad23e5
commit f310646868
6 changed files with 26 additions and 30 deletions
@@ -18,9 +18,13 @@ public abstract class BaseViewExtension<TTarget> implements FlashExtension {
if (k.isEmpty()) {
throw new IllegalArgumentException("global key must not be blank");
}
if (k.equals("global") || k.contains(".")) {
if (k.contains(".")) {
throw new IllegalArgumentException("global key must be a simple key (no dots), received: " + key);
}
boolean duplicate = globals.stream().anyMatch(g -> g.key().equals(k));
if (duplicate) {
throw new IllegalArgumentException("global key '" + k + "' is already registered");
}
globals.add(new GlobalValue(k, Objects.requireNonNull(resolver, "global resolver must not be null")));
return this;
}