# How to validate a list of values against a set

**URL:** <https://discourse.greatexpectations.io/t/how-to-validate-a-list-of-values-against-a-set/1473>\
**Category:** GX Core Support\
**Tags:** how-to, help-wanted, types-of-expectation\
**Created:** [November 3, 2023, 4:33pm UTC](https://discourse.greatexpectations.io/t/how-to-validate-a-list-of-values-against-a-set/1473 "2023-11-03T16:33:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakethesdet](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@jakethesdet](https://discourse.greatexpectations.io/u/jakethesdet)\
**Post date:** [November 3, 2023, 4:33pm UTC](https://discourse.greatexpectations.io/t/how-to-validate-a-list-of-values-against-a-set/1473/1 "2023-11-03T16:33:30Z")

</div>

Hello! I’m looking for some information on how to validate a list of strings in a column against a preset list of values.

Here is an example:  
data column = “Codes”: value = [“01”,“02”,“03”,“04”,“05”]  
value\_set = [“01”,“02”,“03”,“04”,“05”,“06”,“07”,“08”,“09”,“10”]

What I am trying to to do is loop through the “Codes” list and compare each value in the list against each value in the value\_set list. This example here should pass because each value in codes exists in the value set.

If a row had a column “Codes” with a value [“01”,“02”,“W”,“X”,“03”] I would expect this to fail.

I have tried these so far but they are not working for me.  
expect\_column\_values\_to\_match\_like\_pattern\_list  
expect\_column\_values\_to\_be\_in\_set

Thank you for the tips/help in advance!

---

<div class="post-metadata">

**Author:** ![jakethesdet](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@jakethesdet](https://discourse.greatexpectations.io/u/jakethesdet)\
**Post date:** [November 9, 2023, 3:22pm UTC](https://discourse.greatexpectations.io/t/how-to-validate-a-list-of-values-against-a-set/1473/2 "2023-11-09T15:22:34Z")

</div>

Hello friends! any help out there for this?

---

<div class="post-metadata">

**Author:** ![rachel.house](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/rachel.house/32/236_2.png) [@rachel.house](https://discourse.greatexpectations.io/u/rachel.house)\
**Post date:** [November 13, 2023, 8:58pm UTC](https://discourse.greatexpectations.io/t/how-to-validate-a-list-of-values-against-a-set/1473/3 "2023-11-13T20:58:43Z")

</div>

Hi @jakethesdet, thanks for reaching out!

I’m not aware of any out-of-the-box Expectations that will let you validate a list within each row of your `Codes` column - the list of strings within the cells is what makes this a trickier use case. I think your options here are:

1. You could [create a custom Expectation](https://docs.greatexpectations.io/docs/guides/expectations/custom_expectations_lp/) (I’d check out [Custom Column Map Expectations](https://docs.greatexpectations.io/docs/guides/expectations/creating_custom_expectations/how_to_create_custom_column_map_expectations) first) that properly parses the list within each cell and then validates the list contents against your `value_set`.

2. You could preprocess your data before you validate it with GX. If you explode your tabular data on the `Codes` column, you could then use the `expect_column_values_to_be_in_set` expectation to validated using your `value_set`, and it will fail on individual `Codes` values. With this approach, you could have multiple failures for the same original row - depending on your use case, you might need to do some post-processing on the Expectation output to get a clean report on which rows failed validation.

---

<div class="post-metadata">

**Author:** ![jakethesdet](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@jakethesdet](https://discourse.greatexpectations.io/u/jakethesdet)\
**Post date:** [November 14, 2023, 7:30pm UTC](https://discourse.greatexpectations.io/t/how-to-validate-a-list-of-values-against-a-set/1473/4 "2023-11-14T19:30:21Z")

</div>

Thank you for this! It is what I was expecting but wanted to make sure before diving in!
