{"id":"17f8e49e3b26db41","repo":"sequelize/sequelize","slug":"value-for-key-option-must-be-a-string-or-a-bo","errorCode":null,"errorMessage":"Value for \"${key}\" option must be a string or a boolean, got ${typeof this.options[key]}","messagePattern":"Value for \"(.+?)\" option must be a string or a boolean, got (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/model-definition.ts","lineNumber":299,"sourceCode":"      } catch (error) {\n        throw new BaseError(\n          `An error occurred for attribute ${attributeName} on model ${this.modelName}.`,\n          { cause: error },\n        );\n      }\n\n      rawAttributes[attributeName] = rawAttribute;\n\n      if (rawAttribute.field) {\n        fieldToColumn();\n      }\n    }\n\n    // setup names of timestamp attributes\n    if (this.options.timestamps) {\n      for (const key of ['createdAt', 'updatedAt', 'deletedAt'] as const) {\n        if (!['undefined', 'string', 'boolean'].includes(typeof this.options[key])) {\n          throw new Error(\n            `Value for \"${key}\" option must be a string or a boolean, got ${typeof this.options[key]}`,\n          );\n        }\n\n        if (this.options[key] === '') {\n          throw new Error(`Value for \"${key}\" option cannot be an empty string`);\n        }\n      }\n\n      if (this.options.createdAt !== false) {\n        this.timestampAttributeNames.createdAt =\n          typeof this.options.createdAt === 'string' ? this.options.createdAt : 'createdAt';\n\n        this.#readOnlyAttributeNames.add(this.timestampAttributeNames.createdAt);\n      }\n\n      if (this.options.updatedAt !== false) {\n        this.timestampAttributeNames.updatedAt =","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/sequelize/sequelize/blob/7e1deec499d5afbb8d1877c2f4d545cead1214ec/packages/core/src/model-definition.ts#L281-L317","documentation":"When `timestamps` is enabled, the constructor iterates createdAt/updatedAt/deletedAt (model-definition.ts:297-302) and asserts each is `undefined`, `string`, or `boolean`. Any other type (number, object, array) throws a plain Error because Sequelize uses these options either to rename a timestamp attribute (string), disable it (false), or leave it as default (undefined/true).","triggerScenarios":"Passing `{ timestamps: true, createdAt: 1 }`, `{ createdAt: { field: 'ca' } }`, or any non-string/non-boolean value for a timestamp option.","commonSituations":"Typo where a column-name string is replaced by a number; passing a config object instead of a string; misreading the API and providing `createdAt: 'ca'`-shaped objects.","solutions":["Use a string to rename the attribute, e.g. `createdAt: 'created_at'`.","Use `false` to disable that timestamp, or omit it to keep the default name.","If you need to customize the column name separately, set the option to a string and adjust the attribute's `field`/`columnName`."],"exampleFix":"// before\nUser.init(attrs, { sequelize, timestamps: true, createdAt: { field: 'created_at' } });\n\n// after\nUser.init(attrs, { sequelize, timestamps: true, createdAt: 'created_at' });","handlingStrategy":"validation","validationCode":"function assertTimestampOpts(opts) {\n  if (!opts.timestamps) return;\n  for (const key of ['createdAt', 'updatedAt', 'deletedAt']) {\n    const v = opts[key];\n    if (v !== undefined && typeof v !== 'string' && typeof v !== 'boolean') {\n      throw new Error(`${key} must be string|boolean|undefined, got ${typeof v}`);\n    }\n  }\n}\nassertTimestampOpts(modelOptions);","typeGuard":"function isTimestampOptValue(v) {\n  return v === undefined || typeof v === 'string' || typeof v === 'boolean';\n}","tryCatchPattern":null,"preventionTips":["Use only string (rename), false (disable), or omit for timestamp options.","Set the attribute columnName/field separately if you need a custom DB column.","Type the options as ModelOptions so a number/object is a compile error."],"tags":["config","timestamps"],"analyzedSha":"7e1deec499d5afbb8d1877c2f4d545cead1214ec","analyzedAt":"2026-08-03T18:58:44.549Z","schemaVersion":2}