<p>I'm installing up a helm chart using <code>helm install</code> command. I have <code>values.yaml</code> which takes a few inputs from the user. One of the keys in <code>values.yaml</code> is <em>action</em>, which can only take three predefined values (let's say <em>action1</em>, <em>action2</em> and <em>action3</em>) as an input. Any other value other than this is invalid.</p>

<p>When a user provides the value to action field in <code>values.yaml</code> and trigger the <code>helm install</code> command, the first thing I need to check is that if the <em>action</em> key has a valid value or not. If the <em>action</em> value is invalid, I want the release to be failed with a proper error message.</p>

<p>e.g.: In case the user has given <code>action: action4</code>, this is not valid and release should fail as <code>.Values.action</code> can only be <em>action1</em>, <em>action2</em>, or <em>action3</em>.</p>

<p>How I can achieve this use case and which file should be best to handle this validation considering the helm structure?</p>

<p>I was able to achieve the use case with below changes.
Added the following code in _helpers.tpl</p>

<pre><code>{{- define "actionValidate" -}}
  {{ $action := .Values.actions }}
  {{- if or (eq $action "action1") (eq $action "action2") (eq $action "action3") -}}
    true
  {{- end -}}
{{- end -}}
</code></pre>

<p>Invoked this function from a .tpl file like this:-</p>

<pre><code>{{ include "actionValidate" .  | required "Action value is incorrect. The valid values are 'action1', 'action2', 'action3' " }}
</code></pre>
