-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba927f2
commit ddc6ed6
Showing
3 changed files
with
16 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,7 +181,7 @@ export class Email extends Value<string> { | |
} | ||
} | ||
|
||
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('[email protected]') | ||
const email = makeEmail('[email protected]') | ||
|
||
console.log(email.value) // "[email protected]" | ||
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('[email protected]'), | ||
email: makeEmail('[email protected]'), | ||
}) | ||
|
||
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('[email protected]'), | ||
email: makeEmail('[email protected]'), | ||
}) | ||
|
||
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('[email protected]'), | ||
email: makeEmail('[email protected]'), | ||
}) | ||
|
||
user.subscribe('register-account', (event: RegisterAccountEvent) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ class Email extends Value<string> { | |
} | ||
} | ||
|
||
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 = '[email protected]' | ||
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 = '[email protected]' | ||
const vo1 = createEmail(email1) | ||
const vo1 = makeEmail(email1) | ||
|
||
const email2 = '[email protected]' | ||
const vo2 = createEmail(email2) | ||
const vo2 = makeEmail(email2) | ||
|
||
expect(vo1.value).toBe(email1) | ||
expect(vo2.value).toBe(email2) | ||
|