# Validation check

{% hint style="info" %}
To enable advanced validation checks in answer options for your multiple choice question, import the library as described in the [getting-started](https://synoint.gitbook.io/survey-library/getting-started "mention") section.
{% endhint %}

Once you have completed the main steps, you will need to modify the parameters in the provided template snippet to apply the changes.

<table><thead><tr><th>Variable</th><th>Example</th></tr></thead><tbody><tr><td><strong><code>question_code</code></strong><br><br>The code of the single choice question you want to configure</td><td><pre class="language-javascript"><code class="lang-javascript">multiple_choice({
<strong>    question_code: "Q1"
</strong>});
</code></pre></td></tr><tr><td><strong><code>schema</code></strong><br><br>This variable represents an <mark style="color:blue;"><strong>open text field</strong></mark> where answer codes will be stored. It is only required if you plan to use this question to <mark style="color:red;"><strong>filter</strong></mark> or <mark style="color:red;"><strong>randomize in the same order</strong></mark>. Remove it if not needed.<br><br><span data-gb-custom-inline data-tag="emoji" data-code="1f4a1">💡</span> Use a descriptive name for the schema that indicates it is associated with a specific question code, such as <code>Q1_SCHEMA</code> or <code>Q1xSCHEMA</code><br><br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> <em>Te open text should be placed in the same page of the multiple choice.</em><br><img src="https://3256950692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8ViByLqKSYWJoXIHUUnY%2Fuploads%2F3e3ClosuOgnE57zgEGh1%2Fimage.png?alt=media&#x26;token=a138db89-fc20-45ee-bae0-891477657d21" alt=""></td><td><pre class="language-javascript"><code class="lang-javascript">multiple_choice({
    question_code: "Q1",
<strong>    schema: "Q1xSCHEMA"
</strong>});
</code></pre></td></tr><tr><td><p><strong><code>validation</code></strong><br><br>This section defines the settings for validating the selected options. </p><p></p><p>You can delete this code block and skip this tutorial if you don’t need validation. <span data-gb-custom-inline data-tag="emoji" data-code="1f44d">👍</span></p></td><td><pre class="language-javascript"><code class="lang-javascript">multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
<strong>    validation: {
</strong><strong>    
</strong><strong>    }
</strong>});
</code></pre></td></tr><tr><td><p><strong><code>validation</code></strong> -> <strong><code>n_required</code></strong><br><br>This variable lets you set a required number of options to be selected. <br><br>If the user selects fewer than <mark style="color:red;"><strong>n_required</strong></mark> options, an error message will be displayed. If the user selects exactly <mark style="color:red;"><strong>n_required</strong></mark> options, any remaining options will be disabled.</p><p></p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f4a1">💡</span>Use this variable when you need an exact number of selected options.<br><br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> <em>You cannot use this variable together with min_limit and/or max_limit.</em></p></td><td><pre class="language-javascript"><code class="lang-javascript">multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    validation: {
<strong>        n_required: 1
</strong>    }
});
</code></pre></td></tr><tr><td><strong><code>validation</code></strong> -> <strong><code>min_limit</code></strong><br><br>This variable lets you set a minimum number of options to be selected.<br><br>If the user selects less than <mark style="color:red;"><strong>min_limit</strong></mark> options, an error message will be displayed.<br><br><span data-gb-custom-inline data-tag="emoji" data-code="1f4a1">💡</span>You can use this variable alone or together with <mark style="color:red;"><strong>max_limit</strong></mark> to limit the range of selected options.<br><br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> <em>You cannot use this variable together with n_required.</em></td><td><pre class="language-javascript"><code class="lang-javascript">multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    validation: {
<strong>        min_limit: 1
</strong>    }
});
</code></pre></td></tr><tr><td><p><strong><code>validation</code></strong> -> <strong><code>max_limit</code></strong><br><br>This variable lets you set a maximum number of options to be selected.<br><br>If the user reaches the <mark style="color:red;"><strong>max_limit</strong></mark> of selected options, any remaining options will be disabled.</p><p><br><span data-gb-custom-inline data-tag="emoji" data-code="1f4a1">💡</span>You can use this variable alone or together with <mark style="color:red;"><strong>min_limit</strong></mark> to limit the range of selected options.<br><br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> <em>You cannot use this variable together with n_required.</em></p></td><td><pre class="language-javascript"><code class="lang-javascript">multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    validation: {
        min_limit: 1,
<strong>        max_limit: 2
</strong>    }
});
</code></pre></td></tr></tbody></table>
