Skip to content

Commit

Permalink
updated error messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-jonathan committed Apr 30, 2024
1 parent ba927f2 commit ddc6ed6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/Aggregate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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),
})

Expand Down Expand Up @@ -198,7 +198,7 @@ describe('Aggregate', () => {
createdAt,
name,
version,
email: createEmail(email),
email: makeEmail(email),
})

a1.subscribe('register-user-account-sync', (event: UserRegisterEvent) => {
Expand Down
10 changes: 5 additions & 5 deletions __tests__/Value.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
Expand All @@ -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())
})
Expand All @@ -95,7 +95,7 @@ describe('Value', () => {

it('ValidationError', () => {
try {
createEmail('123')
makeEmail('123')
expect(true).toBeFalsy()
}
catch (error) {
Expand All @@ -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)
Expand Down

0 comments on commit ddc6ed6

Please sign in to comment.