Hello Roy Golan,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/39395
to review the following change.
Change subject: core: validator - include range as constraint message
......................................................................
core: validator - include range as constraint message
when using a @ConfiguredRange it is best to include in the CDA message
the actual range that was used and this patch add a constraint
violations message - which is interpolated on as a CDA variable to use
so now use ${range} in your AppErrors messages
SOME_RANGE_ERROR=input out of range ${range}
Change-Id: Icc8813288958fdc9a66548c3a013a928d370e28c
Signed-off-by: Roy Golan <[email protected]>
---
M
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/ConfiguredRangeValidator.java
1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/39395/1
diff --git
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/ConfiguredRangeValidator.java
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/ConfiguredRangeValidator.java
index 1ca0d8f..26d9a5c 100644
---
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/ConfiguredRangeValidator.java
+++
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/validation/ConfiguredRangeValidator.java
@@ -12,6 +12,7 @@
private int min;
private int max;
+ private String rangeMessage;
@Override
public void initialize(ConfiguredRange constraintAnnotation) {
@@ -22,10 +23,17 @@
}
max = Config.<Integer> getValue(constraintAnnotation.maxConfigValue(),
ConfigCommon.defaultConfigurationVersion);
+ rangeMessage = "$range " + min + "-" + max;
+
}
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
- return value == null ? true : value >= min && value <= max;
+ boolean result = value == null ? true : value >= min && value <= max;
+ if (!result) {
+ context.buildConstraintViolationWithTemplate(rangeMessage);
+ }
+ return result;
}
+
}
--
To view, visit https://gerrit.ovirt.org/39395
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc8813288958fdc9a66548c3a013a928d370e28c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Tomer Saban <[email protected]>
Gerrit-Reviewer: Roy Golan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches