fix: enhance global key validation and update template parameters
This commit is contained in:
+5
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user