diff --git a/README.md b/README.md index b682574..eedcb97 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ export class Email extends Value { } } -export const createEmail = defineValue(Email, { +export const makeEmail = defineValue(Email, { created(email): void { // ... do something }, @@ -200,10 +200,10 @@ export const createEmail = defineValue(Email, { ```typescript import { - createEmail, + makeEmail, } from './Email' -const email = createEmail('me@domain.com') +const email = makeEmail('me@domain.com') console.log(email.value) // "me@domain.com" console.log(email.domainAddress) // "domain.com" @@ -272,14 +272,14 @@ import { } from './User' import { - createEmail, + makeEmail, } from './Email' const user = makeUser({ id: '123', name: 'Daniel', age: 29, - email: createEmail('me@domain.com'), + email: makeEmail('me@domain.com'), }) console.log(user.id) // "123" @@ -391,14 +391,14 @@ import { } from './UserAggregate' import { - createEmail, + makeEmail, } from './Email' const user = makeUserAggregate({ id: '123', name: 'Daniel', age: 29, - email: createEmail('me@domain.com'), + email: makeEmail('me@domain.com'), }) console.log(user.id) // "123" @@ -507,14 +507,14 @@ import { } from './UserAggregate' import { - createEmail, + makeEmail, } from './Email' const user = makeUserAggregate({ id: '123', name: 'Daniel', age: 29, - email: createEmail('me@domain.com'), + email: makeEmail('me@domain.com'), }) user.subscribe('register-account', (event: RegisterAccountEvent) => { diff --git a/__tests__/Aggregate.spec.ts b/__tests__/Aggregate.spec.ts index 467f9d0..a20b9a3 100644 --- a/__tests__/Aggregate.spec.ts +++ b/__tests__/Aggregate.spec.ts @@ -62,7 +62,7 @@ class Email extends Value { } } -const createEmail = defineValue(Email, { +const makeEmail = defineValue(Email, { validator: (value: string): boolean => 'string' === typeof string().email('email is invalid').strict(true).validateSync(value), }) @@ -198,7 +198,7 @@ describe('Aggregate', () => { createdAt, name, version, - email: createEmail(email), + email: makeEmail(email), }) a1.subscribe('register-user-account-sync', (event: UserRegisterEvent) => { diff --git a/__tests__/Value.spec.ts b/__tests__/Value.spec.ts index ecf3e25..1178e9e 100644 --- a/__tests__/Value.spec.ts +++ b/__tests__/Value.spec.ts @@ -58,7 +58,7 @@ class Email extends Value { } } -const createEmail = defineValue(Email, { +const makeEmail = defineValue(Email, { validator: (value: string): boolean => 'string' === typeof string().email('email is invalid').strict(true).validateSync(value), }) @@ -72,7 +72,7 @@ const makeVersionValue = defineValue(Version, { describe('Value', () => { it('create value', () => { const email = 'ME@domain.com' - const vo = createEmail(email) + const vo = makeEmail(email) expect(vo.value).not.toBe(email) expect(vo.value).toBe(email.toLowerCase()) }) @@ -95,7 +95,7 @@ describe('Value', () => { it('ValidationError', () => { try { - createEmail('123') + makeEmail('123') expect(true).toBeFalsy() } catch (error) { @@ -111,10 +111,10 @@ describe('Value', () => { it('get computed value', () => { const email1 = 'me@domain.com' - const vo1 = createEmail(email1) + const vo1 = makeEmail(email1) const email2 = 'you@domain.com' - const vo2 = createEmail(email2) + const vo2 = makeEmail(email2) expect(vo1.value).toBe(email1) expect(vo2.value).toBe(email2)