{"record":{"id":"1220056db04e822b","repo":"Semantic-Org/Semantic-UI","slug":"name-must-have-a-value","errorCode":null,"errorMessage":"{name} must have a value","messagePattern":"(.+?) must have a value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/definitions/behaviors/form.js","lineNumber":1254,"sourceCode":"  regExp: {\n    htmlID  : /^[a-zA-Z][\\w:.-]*$/g,\n    bracket : /\\[(.*)\\]/i,\n    decimal : /^\\d+\\.?\\d*$/,\n    email   : /^[a-z0-9!#$%&'*+\\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,\n    escape  : /[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g,\n    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',","sourceCodeStart":1236,"sourceCodeEnd":1272,"githubUrl":"https://github.com/Semantic-Org/Semantic-UI/blob/597843ab84d565cccfd8fd7719416350ae73e734/src/definitions/behaviors/form.js#L1236-L1272","documentation":"This is a validation prompt (user-facing message) used by Semantic UI's Form module. It is displayed when a field with the 'empty' validation rule fails because the field's value is undefined, an empty string, or an empty array. The prompt is retrieved via module.get.prompt() (form.js:440-442) which looks up settings.prompt[ruleName], and the {name} placeholder is replaced with the field's label text or placeholder.","triggerScenarios":"A field is configured with rules: [{ type: 'empty' }] and the user submits or blurs the field with no value. The validate.rule() function (form.js:1014) calls the 'empty' rule function (form.js:1337-1338) which returns false when value === undefined || value === '' || (isArray && length === 0), triggering the prompt.","commonSituations":"Required form fields left empty on submit. Fields where the user enters only whitespace (depending on whether trimming is configured). Dynamically added fields that lose their value. Select elements with no option chosen. Hidden fields that were programmatically cleared.","solutions":["Ensure the user provides a value before form submission (this prompt IS the solution for empty required fields).","Customize the prompt text to be more specific: settings.prompt.empty = 'Please enter your {name}'.","Set the field's label text so {name} resolves to a meaningful field name.","If the field is genuinely optional, add optional: true to the field's validation config or remove the 'empty' rule."],"exampleFix":"// before\n$('.ui.form').form({\n  name: { rules: [{ type: 'empty', prompt: '{name} must have a value' }] }\n  // generic prompt\n});\n\n// after\n$('.ui.form').form({\n  name: {\n    identifier: 'name',\n    rules: [{ type: 'empty', prompt: 'Please enter your full name' }]\n  }\n});","handlingStrategy":"validation","validationCode":"// Pre-validate required fields before form submission\nfunction validateRequired($form) {\n  var valid = true;\n  $form.find('[data-validate=\"empty\"]').each(function() {\n    if (!$(this).val()) {\n      valid = false;\n      console.warn('Field is empty:', $(this).attr('name'));\n    }\n  });\n  return valid;\n}\nif (validateRequired($('.ui.form'))) {\n  $('.ui.form').form('validate form');\n}","typeGuard":"// Check if a field has a non-empty value\nfunction isFieldFilled($field) {\n  var val = $field.val();\n  return val !== undefined && val !== '' && !($.isArray(val) && val.length === 0);\n}","tryCatchPattern":null,"preventionTips":["Use HTML5 required attributes as a first line of defense.","Customize prompt messages to be specific and actionable.","Set meaningful label text so {name} resolves to a clear field name."],"tags":["form","validation","required-field","prompt","semantic-ui"],"backgroundTag":null,"analyzedSha":"597843ab84d565cccfd8fd7719416350ae73e734","analyzedAt":"2026-08-13T01:44:23.827Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}