Semantic-Org/Semantic-UI · warning
{name} must contain "{ruleValue}"
Error message
{name} must contain "{ruleValue}" What it means
Default prompt keyed under `contain` in settings.prompt (form.js:1266). IMPORTANT quirk: the rule FUNCTION is named `contains` (form.js:1458) — there is no `settings.rules.contain`. Because `module.get.ruleName` (form.js:395) returns the rule type verbatim, using `{type:'contain[...]'}` yields ruleName `contain`, `settings.rules['contain']` is undefined, and `module.error(error.noRule)` fires (form.js:1024-1026). The intended usage is `{type:'contains[...]'}`, but then the prompt lookup `settings.prompt['contains']` is undefined and falls back to `unspecifiedRule`. So this `contain` message is effectively unreachable unless you set an explicit `rule.prompt`.
Source
Thrown at src/definitions/behaviors/form.js:1266
text: {
unspecifiedRule : 'Please enter a valid value',
unspecifiedField : 'This field'
},
prompt: {
empty : '{name} must have a value',
checked : '{name} must be checked',
email : '{name} must be a valid e-mail',
url : '{name} must be a valid url',
regExp : '{name} is not formatted correctly',
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',View on GitHub (pinned to 597843ab84)
Solutions
- Use the correct rule type `contains[...]` AND supply an explicit `prompt`, since the default `contain` key is never matched.
- Add the missing alias globally: `$.fn.form.settings.rules.contain = $.fn.form.settings.rules.contains; $.fn.form.settings.prompt.contains = $.fn.form.settings.prompt.contain;`.
- If you only need the message, set `rules:[{type:'contains[abc]', prompt:'Must contain "abc"'}]`.
Example fix
// before - prompt key 'contain' never resolves
rules: [{ type: 'contains[abc]' }] // shows 'Please enter a valid value'
// after - explicit prompt makes the message correct
rules: [{ type: 'contains[abc]', prompt: 'Value must contain "abc"' }] Defensive patterns
Strategy: validation
Validate before calling
const needle = 'abc';
if (($field.val() || '').toLowerCase().indexOf(needle.toLowerCase()) === -1) { /* warn */ } Type guard
const usesContainsRule = (rule) => /^contains(\[.*\])?$/.test(rule.type || '');
Prevention
- Use type 'contains[...]' (not 'contain') and set an explicit prompt — the default 'contain' key is never matched.
- Register aliases once at startup if you prefer the 'contain' spelling.
- Test that the expected message actually renders.
When it happens
Trigger: Intended: `{type:'contains[abc]'}` with input lacking `abc` (case-insensitive substring). Actual: either a `noRule` console error (if you wrote `contain`), or the generic 'Please enter a valid value' fallback (because the prompt key does not match the function name).
Common situations: Developers following docs that mention `contain` and finding the message never appears, or seeing `noRule` errors in the console.
Related errors
- {name} must contain exactly "{ruleValue}"
- {name} cannot contain "{ruleValue}"
- {name} cannot contain exactly "{ruleValue}"
- {name} must be a valid url
- {name} is not formatted correctly
AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13).
Data as JSON: /api/errors/f7c29f95fbcb9d16.
Report an issue: GitHub.