Configuration : validation of property values


Is there any plan to have validation of Configuration values at some point ? The current implementation is elegant and well fledged, but it could use validation.

For instance if I define a property as a String, I would like to be able to define that it can hold only two different values “ABC” or “XYZ”.

Of course it can done later in the code, but ideally the framework would help to handle it with a pretty localized message.


Hi Mike,

Do you mean validating user input in the Application Properties screen?

You know, the property values can also be set/overridden in a number of ways: directly in the database, via JMX bean, in property files, as Java system properties…

Sorry Konstantin, I was not clear enough.

I was speaking about the Configuration interface mechanism provided by CUBA. I have created one that is a String that can take two values ‘warn’ and ‘info’ (see code below).

I would like that if someone changes the value in the file there is a validation at code level when unfetching the value. It is likely possible to validate inputs in Application Properties screen (did not look into it yet), but we all come from Unix and are more inclined to edit configuration files than using a GUI for editing.

OFC for now I have coded the validation myself and others will follow, but with CUBA you get used to have all platform features that you can think of implemented and not think about them anymore :slight_smile:

@Source(type = SourceType.APP)
public interface BusyConfig extends Config {
    String getLogSendToGuiLevel();

Agree, that would be helpful both in UI and when reading the value. An exception is usually better than using an invalid value. So I’ve converted this topic to idea and added a YouTrack issue.

Thank you!

:ticket: See the following issue in our bug tracker: