Semantic-Org/Semantic-UI · warning
{name} must have exactly {ruleValue} choices
Error message
{name} must have exactly {ruleValue} choices What it means
Semantic UI Form 'exactCount' rule message. The rule function (form.js:1683) requires the comma-split item count to equal ruleValue exactly; otherwise this prompt is shown with {name} and {ruleValue} interpolated. Special-cases 0 (requires no value) and 1 (requires any non-empty value).
Source
Thrown at src/definitions/behaviors/form.js:1278
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
- Adjust the selection count up or down so it equals exactCount exactly.
- If a range is acceptable, switch to minCount/maxCount instead of exactCount.
- Verify exactCount isn't paired with single-value text inputs - the count is comma-delimited, not character length.
Example fix
// before
rules: [{ type: 'exactCount[3]' }] // user picked 2
// after
rules: [{ type: 'minCount[2]' }, { type: 'maxCount[3]' }] Defensive patterns
Strategy: validation
Validate before calling
function meetsExactCount(fieldId, n) {
return document.querySelectorAll('input[name="' + fieldId + '"]:checked').length === n;
}
if (!meetsExactCount('tags', 3)) { /* guide the user before submit */ } Type guard
function isExactCountRule(rule) {
return typeof rule === 'object' && typeof rule.type === 'string' && /^exactCount\[\d+\]$/.test(rule.type);
} Prevention
- Prefer minCount+maxCount when an exact count is not strictly required.
- Disable the submit button until the exact count is met.
- Surface the expected count clearly to users.
When it happens
Trigger: Declared on a checkbox/multi-value field via rules:[{type:'exactCount[N]'}] and the number of comma-separated selected items differs from N (e.g. user picks 2 when exactCount is 3, or 4 when it is 3).
Common situations: Pick-exactly-N UX (e.g. choose 3 priorities), bulk-edit flows where the count must match, or accidental reuse of exactCount when minCount/maxCount was intended.
Related errors
- {name} must have at least {ruleValue} choices
- {name} must have {ruleValue} or less choices
- {name} must be a valid url
- {name} is not formatted correctly
- {name} must be an integer
AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13).
Data as JSON: /api/errors/f7215d2e8f2fa253.
Report an issue: GitHub.