title: Python dataclass: Check that a field is in list of possible values
body: <p>I want a field in a Python dataclass to only have certain possible values.
  For instance, I want a <code>Jewel</code> dataclass, whose field <code>material</code> can only accept values &quot;gold&quot;, &quot;silver&quot;, and &quot;platinum&quot;.
  I came up with this solution:</p>
  <pre class="lang-py prettyprint-override"><code>@dataclass
  class Jewel:
      kind: str
      material: str
      
      def __post_init__(self):
          ok_materials = [&quot;gold&quot;, &quot;silver&quot;, &quot;platinum&quot;]
          if self.material not in ok_materials:
              raise ValueError(f&quot;Only available materials: {ok_materials}.&quot;)
  </code></pre>
  <p>So, <code>Jewel(&quot;earrings&quot;, &quot;silver&quot;)</code> would be ok, whereas <code>Jewel(&quot;earrings&quot;, &quot;plastic&quot;)</code> would raise a <code>ValueError</code>.</p>
  <p>Is there a better or more pythonic way to achieve this? Maybe something that relies on features from dataclasses module?</p>