Validate properties when creating the configuration instance

11 views
Skip to first unread message

Evandro Pomatti

unread,
Aug 24, 2015, 1:20:31 PM8/24/15
to owner-api
Hi

Is it possible to validate the value of properties when creating the config instance? I would like that the creation of a config instance fail upon the startup of the system if some properties are invalid.

For example, I have the following config:

public interface MyConfigs extends Config {
   
@Key("myconfs.url")
   
public URL url;
}

And I try to create a config instance with the following properties, using an invalid URL:

myconfs.url=xyz%$invalidurl

Can I validate it when calling "ConfigFactory.create()"? Or even simpler, validate an Integer number.

I read the documentation but I did not found any feature related to it. Did I miss anything?

Currently I have implemented a explicit call to each property that is mandatory, but it would be nice if the library did it for me so some code would be saved.

thanks!
Reply all
Reply to author
Forward
0 new messages