{"record":{"id":"2da18ee49a18e565","repo":"Semantic-Org/Semantic-UI","slug":"name-must-be-a-decimal-number","errorCode":null,"errorMessage":"{name} must be a decimal number","messagePattern":"(.+?) must be a decimal number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/definitions/behaviors/form.js","lineNumber":1260,"sourceCode":"    flags   : /^\\/(.*)\\/(.*)?/,\n    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',","sourceCodeStart":1242,"sourceCodeEnd":1278,"githubUrl":"https://github.com/Semantic-Org/Semantic-UI/blob/597843ab84d565cccfd8fd7719416350ae73e734/src/definitions/behaviors/form.js#L1242-L1278","documentation":"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.","triggerScenarios":"`{type:'decimal'}` with input `-2.5`, `.75`, `abc`, `1,5` (comma decimal), or an empty string.","commonSituations":"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.","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."],"exampleFix":"// before - rejects -2.5 because regExp.decimal has no optional sign\nrules: [{ type: 'decimal' }]\n\n// after - accept signed decimals\nrules: [{ type: 'regExp', value: /^-?\\d+\\.?\\d*$/, prompt: 'Enter a decimal number' }]","handlingStrategy":"validation","validationCode":"// Accept signed decimals (the built-in regExp.decimal does not)\nconst decimalOk = /^-?\\d+\\.?\\d*$/.test($field.val().replace(',', '.'));\nif (!decimalOk) { /* warn */ }","typeGuard":"const isSignedDecimal = (v) => /^-?\\d+\\.?\\d*$/.test(String(v).trim());","tryCatchPattern":null,"preventionTips":["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."],"tags":["semantic-ui","form-validation","decimal","regex-quirk","client-side"],"backgroundTag":null,"analyzedSha":"597843ab84d565cccfd8fd7719416350ae73e734","analyzedAt":"2026-08-13T01:44:23.827Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}