Semantic-Org/Semantic-UI · warning

{name} must have at least {ruleValue} choices

Error message

{name} must have at least {ruleValue} choices

What it means

A Semantic UI Form validation message emitted by the 'minCount' rule. The rule (form.js:1673) splits the field value on commas and asserts the resulting item count is >= ruleValue; otherwise the bound prompt/error message replaces {name} with the field label and {ruleValue} with the configured minimum. It is the multi-select/checkbox-group analogue of 'minLength' for character counts.

Source

Thrown at src/definitions/behaviors/form.js:1277

    integer              : '{name} must be an integer',
    decimal              : '{name} must be a decimal number',
    number               : '{name} must be set to a number',
    is                   : '{name} must be "{ruleValue}"',
    isExactly            : '{name} must be exactly "{ruleValue}"',
    not                  : '{name} cannot be set to "{ruleValue}"',
    notExactly           : '{name} cannot be set to exactly "{ruleValue}"',
    contain              : '{name} must contain "{ruleValue}"',
    containExactly       : '{name} must contain exactly "{ruleValue}"',
    doesntContain        : '{name} cannot contain  "{ruleValue}"',
    doesntContainExactly : '{name} cannot contain exactly "{ruleValue}"',
    minLength            : '{name} must be at least {ruleValue} characters',
    length               : '{name} must be at least {ruleValue} characters',
    exactLength          : '{name} must be exactly {ruleValue} characters',
    maxLength            : '{name} cannot be longer than {ruleValue} characters',
    match                : '{name} must match {ruleValue} field',
    different            : '{name} must have a different value than {ruleValue} field',
    creditCard           : '{name} must be a valid credit card number',
    minCount             : '{name} must have at least {ruleValue} choices',
    exactCount           : '{name} must have exactly {ruleValue} choices',
    maxCount             : '{name} must have {ruleValue} or less choices'
  },

  selector : {
    checkbox   : 'input[type="checkbox"], input[type="radio"]',
    clear      : '.clear',
    field      : 'input, textarea, select',
    group      : '.field',
    input      : 'input',
    message    : '.error.message',
    prompt     : '.prompt.label',
    radio      : 'input[type="radio"]',
    reset      : '.reset:not([type="reset"])',
    submit     : '.submit:not([type="submit"])',
    uiCheckbox : '.ui.checkbox',
    uiDropdown : '.ui.dropdown'
  },

View on GitHub (pinned to 597843ab84)

Solutions

  1. Increase the number of selected items to satisfy the displayed minimum, or lower the minCount value in the field rules.
  2. Confirm the field is actually a multi-select/checkbox group; for a single text input use 'minLength' rather than 'minCount'.
  3. Check that the field identifier resolves to the checkbox group and that values join into a comma-separated string as the rule expects.

Example fix

// before
fields: { roles: { rules: [{ type: 'minCount[3]', prompt: '...' }] } } // user only picks 2
// after - either require fewer or provide more selections
fields: { roles: { rules: [{ type: 'minCount[2]' }] } }
Defensive patterns

Strategy: validation

Validate before calling

// Before calling $('.ui.form').form('validate form'), check selection counts
function selectionCount(fieldId) {
  var checked = document.querySelectorAll('input[name="' + fieldId + '"]:checked');
  return checked.length;
}
var minRequired = 3;
if (selectionCount('roles') < minRequired) {
  // show inline guidance instead of relying on the rule firing
}

Type guard

function isValidMinCountConfig(field) {
  return field && Array.isArray(field.rules) && field.rules.some(function(r){
    return typeof r.type === 'string' && /^minCount\[\d+\]$/.test(r.type);
  });
}

Prevention

When it happens

Trigger: Defined on a checkbox group or multi-value field whose value is a comma-joined list (e.g. "on change of a .ui.checkbox group"). Fires when the count of selected items is strictly less than the minCount declared in that field's rules array (rules: [{type:'minCount[3]'}]).

Common situations: Asking the user to pick at least N tags/categories/permissions, but submitting with fewer; mis-typing the rule as 'minLength' (counts characters) instead of 'minCount'; setting minCount on a plain text input whose value has no commas so the count is always 1.

Related errors


AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13). Data as JSON: /api/errors/310af0204d8ab817. Report an issue: GitHub.