# Migration v1 → v2 ## Summary Version 2.0 is a **semver major** release. The npm package exports only `core/` and `catalog/`. Demo DDD code lives under `examples/ddd-demo/` in the repository, not in the published bundle. ## Breaking changes ### 1. Demo removed from npm exports **v1:** ```typescript import { User, EmailAddress } from 'smart-value-objects'; ``` **v2:** ```typescript import { EmailAddress, Title, PersonName, Uuid } from 'smart-value-objects'; // User / use cases: copy from examples/ddd-demo or implement in your app ``` ### 2. EmailAddress API **Removed:** `isCorporateEmail()` **Added:** static factories and constraints ```typescript // v2 const result = EmailAddress.tryCreate(raw, 'email'); if (result.ok) { const domain = result.value.getDomain(); } ``` ### 3. New catalog types - `Title` — max 120 chars - `PersonName` — max 80 chars - `Uuid` — RFC 4122 string UUID ### 4. Validation core ```typescript import { validateRecord, requireRecordObject } from 'smart-value-objects'; ``` Use for multi-field validation with aggregated errors. ## Upgrade checklist - [ ] Replace `string` fields with catalog VOs where applicable - [ ] Switch to `tryCreate` at API/form boundaries - [ ] Remove imports of demo entities from the library - [ ] Bind UI `maxLength` from `X.constraints` - [ ] Copy consumer skill to `.cursor/skills/` if using Cursor agents - [ ] Run tests after bumping dependency to `^4.0.0` ## Version pin ```json "smart-value-objects": "^4.0.0" ``` See [MIGRATION.md](../MIGRATION.md) at repository root for a short pointer to this guide.