{"record":{"id":"f4ce56f42c8356a7","repo":"toeverything/AFFiNE","slug":"table-table-name-field-key-value-va","errorCode":null,"errorMessage":"[Table(${table.name})]: Field '${key}' value '${val}' is not valid. Expected one of [${field.values?.join(', ')}].","messagePattern":"\\[Table\\((.+?)\\)\\]: Field '(.+?)' value '(.+?)' is not valid\\. Expected one of \\[(.+?)\\]\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/common/infra/src/orm/core/validators/data.ts","lineNumber":76,"sourceCode":"          if (val === undefined) {\n            delete data[key];\n            continue;\n          }\n\n          if (val === null) {\n            if (!field.optional) {\n              throw new Error(\n                `[Table(${table.name})]: Field '${key}' is required but not set.`\n              );\n            }\n            continue;\n          }\n\n          const typeGet = inputType(val);\n\n          if (field.type === 'enum') {\n            if (!field.values?.includes(val)) {\n              throw new Error(\n                `[Table(${table.name})]: Field '${key}' value '${val}' is not valid. Expected one of [${field.values?.join(', ')}].`\n              );\n            }\n          } else if (!typeMatches(field.type, typeGet)) {\n            throw new Error(\n              `[Table(${table.name})]: Field '${key}' type mismatch. Expected ${field.type} got ${typeGet}.`\n            );\n          }\n        } else if (!table.isDocumentTable) {\n          // strict check field existence for normal table\n          throw new Error(\n            `[Table(${table.name})]: Field '${key}' is not defined but set in entity.`\n          );\n        }\n      }\n    },\n  },\n  DataTypeShouldExactlyMatch: {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/common/infra/src/orm/core/validators/data.ts#L58-L94","documentation":"A DataTypeShouldMatch validator case for enum fields: the field's schema type is 'enum', but the value supplied is not included in field.values. It fires when the data object assigns a value outside the allowed enum set; the message interpolates the offending field, value, and the full list of permitted values from the schema.","triggerScenarios":"Thrown at packages/common/infra/src/orm/core/validators/data.ts:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of the allowed values listed in the error for this field.","Fix typos or outdated enum values in the data being written.","Update the schema's allowed values if a new value is legitimate."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}