Semantic-Org/Semantic-UI · warning

{name} must be an integer

Error message

{name} must be an integer

What it means

Default prompt for the Semantic UI Form `integer` rule (settings.rules.integer, form.js:1380). Shown when a value fails the integer regex `/^-?\d+$/` (form.js:1243) or falls outside an optional range supplied as `[min..max]`, `[n]`, `[min..]`, or `[..max]`. `{ruleValue}` is replaced with the range string by `module.get.prompt` (form.js:460).

Source

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

    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',
    minCount             : '{name} must have at least {ruleValue} choices',

View on GitHub (pinned to 597843ab84)

Solutions

  1. Enter a whole number within the configured range.
  2. Use exactly two dots in ranges: `integer[1..10]`.
  3. If decimals are valid for your field, switch the rule to `decimal` or `number`.
  4. Add a descriptive `prompt` that states the allowed range.

Example fix

// before
rules: [{ type: 'integer[1...10]' }]  // triple-dot breaks split -> range ignored

// after
rules: [{ type: 'integer[1..10]', prompt: 'Enter a whole number from 1 to 10' }]
Defensive patterns

Strategy: validation

Validate before calling

function inRange(n, min, max) { return Number.isInteger(n) && (min==null||n>=min) && (max==null||n<=max); }
const n = Number($field.val());
if (!inRange(n, 1, 10)) { /* warn */ }

Type guard

const isIntInRange = (v, min, max) => /^-?\d+$/.test(String(v)) && inRange(Number(v), min, max);

Prevention

When it happens

Trigger: `{type:'integer'}` with input `3.5`, `abc`, or empty; `{type:'integer[1..10]'}` with input `0` or `11`; `{type:'integer[18]'}` requiring exactly 18.

Common situations: Allowing decimals where an integer was required, forgetting the range bracket, or a range written as `1...10` (three dots) which breaks the `split('..',2)` logic at form.js:1396.

Related errors


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