Semantic-Org/Semantic-UI · warning
{name} is not formatted correctly
Error message
{name} is not formatted correctly What it means
Default prompt for the Semantic UI Form `regExp` rule (settings.rules.regExp, form.js:1357). Shown when a field's value does not match a caller-supplied regular expression. The rule accepts either a RegExp object or a string (with optional `/pattern/flags` syntax parsed via `settings.regExp.flags`, form.js:1362-1376) passed as the bracketed ancillary value or `rule.value`.
Source
Thrown at src/definitions/behaviors/form.js:1258
email : /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,
escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
flags : /^\/(.*)\/(.*)?/,
integer : /^\-?\d+$/,
number : /^\-?\d*(\.\d+)?$/,
url : /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/i
},
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',View on GitHub (pinned to 597843ab84)
Solutions
- Verify the regex against the intended input in a regex console first.
- Pass the pattern as a real RegExp object via `rule.value` to avoid `/.../ ` parsing edge cases.
- Escape brackets inside the pattern or use `rule.value` when the pattern itself contains `[`/`].`
- Add a custom `prompt` so the failure is actionable, e.g. `'Use 3 uppercase letters'`.
Example fix
// before - bracket parser confused by inner brackets / unanchored
rules: [{ type: 'regExp[/[A-Z]{3}/]' }]
// after - pass RegExp object + clear prompt
rules: [{ type: 'regExp', value: /^[A-Z]{3}$/, prompt: 'Code must be 3 uppercase letters' }] Defensive patterns
Strategy: validation
Validate before calling
const pattern = /^[A-Z]{3}$/; // your rule
if (!pattern.test($field.val())) { /* show inline guidance */ } Type guard
const isRegExpRule = (r) => r && (r.value instanceof RegExp || typeof r.type === 'string' && /\[.*\]/.test(r.type));
Prevention
- Pass RegExp objects via rule.value instead of bracket strings to avoid parser edge cases.
- Unit-test the pattern against representative pass/fail inputs.
- Anchor patterns (^...$) unless partial matching is intended.
When it happens
Trigger: Field rule `{type:'regExp[/^[A-Z]{3}$/]'}` with input `ab` or `abcd`; or `{type:'regExp', value:/\d{4}/}` with input `abc`. Any value for which `value.match(regExp)` is falsy triggers the prompt.
Common situations: Typo in the bracket-delimited regex (unescaped `]`, missing flags), passing a string regex with `/` delimiters inconsistently, or a regex that does not anchor and unexpectedly matches/fails. Also: forgetting that an empty value still runs the rule (use `empty`/`optional` first).
Related errors
- {name} must be a valid url
- {name} must be an integer
- {name} must be a decimal number
- {name} must be set to a number
- {name} must be "{ruleValue}"
AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13).
Data as JSON: /api/errors/d650334a8173b4b4.
Report an issue: GitHub.