-
Notifications
You must be signed in to change notification settings - Fork 485
Dynamic properties validation
allenxwang edited this page Jun 17, 2013
·
1 revision
Applications can define validation rules that apply to dynamic property values. If the validation fails during the update of the dynamic property, a RuntimeException will be thrown and the value of the dynamic property will stay unchanged.
Here is an example where the application validates that the value of a DynamicIntProperty should not be negative:
DynamicIntProperty validatedProp = new DynamicIntProperty("abc", 0) {
@Override
public void validate(String newValue) {
if (Integer.parseInt(newValue) < 0) {
throw new ValidationException("Cannot be negative");
}
}
};