Semantic-Org/Semantic-UI · warning
{name} must be a decimal number
Error message
{name} must be a decimal number What it means
Default prompt for the Semantic UI Form `decimal` rule (settings.rules.decimal, form.js:1412). It tests the value against `settings.regExp.decimal` = `/^\d+\.?\d*$/` (form.js:1239). Note the regex rejects negative numbers and leading-dot decimals: `-1.5`, `.5`, and `-.5` all FAIL despite being valid decimals.
Source
Thrown at src/definitions/behaviors/form.js:1260
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',
minCount : '{name} must have at least {ruleValue} choices',
exactCount : '{name} must have exactly {ruleValue} choices',View on GitHub (pinned to 597843ab84)
Solutions
- If negatives/leading-dot are valid, switch to the `number` rule (regex `/^-?\d*(\.\d+)?$/`).
- Strip a leading sign before validating, or use a custom `regExp` rule like `regExp[/^-?\d+\.?\d*$/]`.
- Replace comma decimals with a dot in a pre-submit handler.
- Provide a custom `prompt` clarifying the expected format.
Example fix
// before - rejects -2.5 because regExp.decimal has no optional sign
rules: [{ type: 'decimal' }]
// after - accept signed decimals
rules: [{ type: 'regExp', value: /^-?\d+\.?\d*$/, prompt: 'Enter a decimal number' }] Defensive patterns
Strategy: validation
Validate before calling
// Accept signed decimals (the built-in regExp.decimal does not)
const decimalOk = /^-?\d+\.?\d*$/.test($field.val().replace(',', '.'));
if (!decimalOk) { /* warn */ } Type guard
const isSignedDecimal = (v) => /^-?\d+\.?\d*$/.test(String(v).trim());
Prevention
- Remember regExp.decimal rejects negatives and leading dots — switch to a custom regex when needed.
- Normalize comma decimals to dots before validation.
- Prefer the number rule when sign support is required.
When it happens
Trigger: `{type:'decimal'}` with input `-2.5`, `.75`, `abc`, `1,5` (comma decimal), or an empty string.
Common situations: Fields that must accept negative amounts or currency; locales using comma decimals; values typed with a leading dot. The regex quirk is the most common surprise.
Related errors
- {name} must be set to a number
- {name} must be a valid url
- {name} is not formatted correctly
- {name} must be an integer
- {name} must be "{ruleValue}"
AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13).
Data as JSON: /api/errors/2da18ee49a18e565.
Report an issue: GitHub.