Set a minimum and maximum for custom multifield elements in CQ5?
<p>I'm currently working on a AEM component that include custom multiefield and I have faced a problem I don't know how to solve it.
I have created a custom widget for this which allows to include multiefield in multiefield. From the documentation read, as I understood there's no default configuration to this for widgets API config.</p>

<p>My dialog nodes:</p>

<pre><code>&lt;questions
    jcr:primaryType="cq:Widget"
    xtype="panel"
    title="Questions"&gt;
    &lt;items jcr:primaryType="cq:WidgetCollection"&gt;
        &lt;quiz-data
                jcr:primaryType="cq:Widget"
                fieldDescription="Click the '+' to add a new data"
                fieldLabel="Quiz"
                name="./quizData"
                xtype="multifield"&gt;
            &lt;fieldConfig
                    jcr:primaryType="cq:Widget"
                    xtype="apps.mypath.widgets.MultieField"/&gt;
        &lt;/quiz-data&gt;
    &lt;/items&gt;
&lt;/questions&gt;
</code></pre>

<p>The widget is working fine, except I want to set a minimum required multiefields and a maximum. I have found on the web a example, but I don't really understand how to do it, take a look at the code bellow:</p>

<pre><code>myNamespace = {};
myNamespace.myCustomFunction = function (dialog) {
    var isValid = function () {
        var valStatus = true;
        ... custom JavaScript/jQuery to check if 3 items exist ...
        return valStatus;
    };
    if (!isValid()) {
        CQ.Ext.Msg.show({title: 'Validation Error', msg: 'Must contain at least 3 items!', buttons: CQ.Ext.MessageBox.OK, icon: CQ.Ext.MessageBox.ERROR});
        return false;
    } else {
        return true;
    }
}
</code></pre>

<p>Would be great, if someone can explain how can I achieve this for my custom multiefield, or any other ideas? Let me know if you have any questions.</p>