{"record":{"id":"3f68002019399ae2","repo":"ruvnet/ruflo","slug":"invalid-domain-object-result-errors-join","errorCode":null,"errorMessage":"Invalid domain object: ${result.errors?.join(', ')}","messagePattern":"Invalid domain object: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/testing/src/helpers/assertion-helpers.ts","lineNumber":330,"sourceCode":"  memoryReduction?: number;\n  startupTimeMs?: number;\n  responseTimeMs?: number;\n}\n\n/**\n * Assert that a domain object is valid\n *\n * @example\n * assertValidDomainObject(user, UserSchema);\n */\nexport function assertValidDomainObject<T>(\n  object: T,\n  validator: (obj: T) => { valid: boolean; errors?: string[] }\n): void {\n  const result = validator(object);\n\n  if (!result.valid) {\n    throw new Error(`Invalid domain object: ${result.errors?.join(', ')}`);\n  }\n}\n\n/**\n * Assert that a mock was only called with allowed arguments\n *\n * @example\n * assertOnlyCalledWithAllowed(mockFn, [['valid1'], ['valid2']]);\n */\nexport function assertOnlyCalledWithAllowed(\n  mock: Mock,\n  allowedCalls: unknown[][]\n): void {\n  const calls = mock.mock.calls;\n\n  for (const call of calls) {\n    const isAllowed = allowedCalls.some(\n      allowed => JSON.stringify(call) === JSON.stringify(allowed)","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/testing/src/helpers/assertion-helpers.ts#L312-L348","documentation":"assertValidDomainObject() runs the supplied validator and throws when it reports valid false, joining the validator error strings into the message. It is a test-time assertion from the testing helpers: the failure means your fixture or factory produced an object that your own schema or validator rejects.","triggerScenarios":"assertValidDomainObject(fixture, SchemaValidator) where the fixture is missing required fields or has wrong-typed fields; factory output drifting from the schema after a schema change.","commonSituations":"Schema updated with a new required field but fixtures not regenerated; validators distinguishing absent from undefined; refactors renaming fields.","solutions":["Read the joined validator errors in the message; they name the exact failing constraints","Fix the fixture or factory to satisfy the current schema, or update the schema if the fixture is the new truth","Run the validator directly on the object while debugging to see the full error list"],"exampleFix":"// before\nassertValidDomainObject({ id: 1 }, UserSchemaValidator); // throws: missing required fields\n\n// after\nassertValidDomainObject(makeValidUser(), UserSchemaValidator);","handlingStrategy":"validation","validationCode":"// Inspect the validator result before asserting, for clearer diagnostics\nconst result = UserSchemaValidator(candidate);\nif (!result.valid) {\n  console.error('fixture validation errors:', result.errors);\n}\nassertValidDomainObject(candidate, UserSchemaValidator);","typeGuard":"function isValidDomainObject<T>(obj: T, validator: (o: T) => { valid: boolean; errors?: string[] }): obj is T {\n  return validator(obj).valid;\n}","tryCatchPattern":null,"preventionTips":["Generate fixtures from the same schema that validates them, one source of truth","Run schema validation over all factories in CI, not only in tests that assert it","When a schema gains a required field, update every factory in the same commit"],"tags":["testing","assertion","validation","test-fixtures"],"backgroundTag":"schema-validation-failed","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}