how can I express, `if the values in this list are...
# getting-started
o
how can I express,
if the values in this list are valid values in my enum
? I am doing this
Copy code
if (queryParams.containsAll(GiveConsent.ConsentType.values())){
but i get this error that it expects a collection and I gave it an Array
j
Even if the code you wrote compiled, it doesn't express what you seem to be wanting in your description. Do you want to check if all values in the list are valid values from this enum, or do you want to check if all values of the enum appear in the list?
I would say you probably want:
Copy code
val validEnumValues = GiveConsent.ConsentType.values().map { it.name }.toSet()
if (queryParams.all { it in validEnumValues }) {
    ...
}
(If your
queryParams
values are strings)
You could also ignore the case depending on your needs (for instance by lowercasing the values in the set, and then lowercasing the params in the
all
)
o
that’s nice actually
make them a set, and then check for whether all items in the list are in the set
thanks Joffrey!