Hi Remko,
me again 🙈I have a question about validating programmatically added values, which boils down to: What is the best/intended way to do this?
I think about using a preprocessor or a custom converter for this case.
A little bit of context: We're parsing values from different config sources and show them as Options in the CLI.
High level, it goes like this:
PropertyMapper OptionBuilder
<quarkusconfig>(1:1,1:n) <-----------------------------> <keycloakconfig>(1:1) <-----------------------> cli option.
Now for the usecase: "db" has some expected values, and so do other options. I want to validate that the value we get from the CLI matches one of the pre-defined values in "supportedDatabaseVendors" array, so that e.g.
<picocli> build --db=foo
fails with the proper validation message, and prints the expected values ("expectedValues" in the builder above).
I think about adding a .validationFunc(Predicate<string>) to the PropertyMapper builder which would then return a converter/preprocessor for each property where validation for correct value is needed, and then add this function in the optionBuilder via .converter(mapper.validationFunc()) (or preprocessor) - but I wanted to make sure first that this is the intended way or if I overlook something.
Would be great to get some hints for the right direction. :)
Thank you for your help.
Best regards,
Dominik