{"record":{"id":"fd044d7593efaa95","repo":"Semantic-Org/Semantic-UI","slug":"name-must-be-set-to-a-number","errorCode":null,"errorMessage":"{name} must be set to a number","messagePattern":"(.+?) must be set to a number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/definitions/behaviors/form.js","lineNumber":1261,"sourceCode":"    integer : /^\\-?\\d+$/,\n    number  : /^\\-?\\d*(\\.\\d+)?$/,\n    url     : /(https?:\\/\\/(?:www\\.|(?!www))[^\\s\\.]+\\.[^\\s]{2,}|www\\.[^\\s]+\\.[^\\s]{2,})/i\n  },\n\n  text: {\n    unspecifiedRule  : 'Please enter a valid value',\n    unspecifiedField : 'This field'\n  },\n\n  prompt: {\n    empty                : '{name} must have a value',\n    checked              : '{name} must be checked',\n    email                : '{name} must be a valid e-mail',\n    url                  : '{name} must be a valid url',\n    regExp               : '{name} is not formatted correctly',\n    integer              : '{name} must be an integer',\n    decimal              : '{name} must be a decimal number',\n    number               : '{name} must be set to a number',\n    is                   : '{name} must be \"{ruleValue}\"',\n    isExactly            : '{name} must be exactly \"{ruleValue}\"',\n    not                  : '{name} cannot be set to \"{ruleValue}\"',\n    notExactly           : '{name} cannot be set to exactly \"{ruleValue}\"',\n    contain              : '{name} must contain \"{ruleValue}\"',\n    containExactly       : '{name} must contain exactly \"{ruleValue}\"',\n    doesntContain        : '{name} cannot contain  \"{ruleValue}\"',\n    doesntContainExactly : '{name} cannot contain exactly \"{ruleValue}\"',\n    minLength            : '{name} must be at least {ruleValue} characters',\n    length               : '{name} must be at least {ruleValue} characters',\n    exactLength          : '{name} must be exactly {ruleValue} characters',\n    maxLength            : '{name} cannot be longer than {ruleValue} characters',\n    match                : '{name} must match {ruleValue} field',\n    different            : '{name} must have a different value than {ruleValue} field',\n    creditCard           : '{name} must be a valid credit card number',\n    minCount             : '{name} must have at least {ruleValue} choices',\n    exactCount           : '{name} must have exactly {ruleValue} choices',\n    maxCount             : '{name} must have {ruleValue} or less choices'","sourceCodeStart":1243,"sourceCodeEnd":1279,"githubUrl":"https://github.com/Semantic-Org/Semantic-UI/blob/597843ab84d565cccfd8fd7719416350ae73e734/src/definitions/behaviors/form.js#L1243-L1279","documentation":"Default prompt for the Semantic UI Form `number` rule (settings.rules.number, form.js:1417). It tests against `settings.regExp.number` = `/^-?\\d*(\\.\\d+)?$/` (form.js:1244). Quirk: the regex matches an empty string `''` and a lone `-`, so those pass validation — pair with an `empty` rule when the field is required.","triggerScenarios":"`{type:'number'}` with input `1.2.3`, `abc`, `--4`, or `3,14` (comma). Empty input or `-` alone do NOT trigger it (they pass).","commonSituations":"Required numeric fields left blank still passing because the regex matches `''`; localized comma decimals; multiple dots in pasted data.","solutions":["Add `empty` as a separate rule if the field is required: `rules:[{type:'empty'},{type:'number'}]`.","Strip grouping separators / replace comma decimals before validation.","Use `integer` or `decimal` when a more specific numeric type is intended.","Provide a custom `prompt`."],"exampleFix":"// before - blank input passes the number regex\nrules: [{ type: 'number' }]\n\n// after - require presence + numeric\nrules: [\n  { type: 'empty', prompt: 'Amount is required' },\n  { type: 'number', prompt: 'Amount must be a number' }\n]","handlingStrategy":"validation","validationCode":"const v = $field.val();\nconst isNumber = /^-?\\d*(\\.\\d+)?$/.test(v);\nconst isRequiredAndBlank = (v === '' || v === '-'); // these PASS the built-in rule!\nif (!isNumber || isRequiredAndBlank) { /* warn */ }","typeGuard":"const isStrictNumber = (v) => v !== '' && v !== '-' && /^-?\\d*(\\.\\d+)?$/.test(String(v));","tryCatchPattern":null,"preventionTips":["Always pair number with an empty rule when the field is required.","Strip thousands separators before validating.","Use integer/decimal for stricter contracts."],"tags":["semantic-ui","form-validation","number","regex-quirk","client-side"],"backgroundTag":null,"analyzedSha":"597843ab84d565cccfd8fd7719416350ae73e734","analyzedAt":"2026-08-13T01:44:23.827Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}