diff --git a/integration/base.ts b/integration/base.ts
index d0e8ae442..25bd6964e 100644
--- a/integration/base.ts
+++ b/integration/base.ts
@@ -69,7 +69,7 @@ import * as Nodemailer from '../src/nodemailer.js'
import { Program } from '../src/Program.js'
import { PublicUrl } from '../src/public-url.js'
import * as TemplatePage from '../src/TemplatePage.js'
-import type { EmailAddress } from '../src/types/email-address.js'
+import { EmailAddress } from '../src/types/email-address.js'
import type { NonEmptyString } from '../src/types/string.js'
import type { WasPrereviewRemovedEnv } from '../src/zenodo.js'
import Logger = L.Logger
@@ -1998,7 +1998,7 @@ export const hasAnUnverifiedEmailAddress: Fixtures<
'0000-0002-1825-0097',
ContactEmailAddressC.encode(
new UnverifiedContactEmailAddress({
- value: 'jcarberry@example.com' as EmailAddress,
+ value: EmailAddress('jcarberry@example.com'),
verificationToken: 'ff0d6f8e-7dca-4a26-b68b-93f2d2bc3c2a' as Uuid,
}),
),
@@ -2016,7 +2016,7 @@ export const hasAVerifiedEmailAddress: Fixtures<
contactEmailAddressStore: async ({ contactEmailAddressStore }, use) => {
await contactEmailAddressStore.set(
'0000-0002-1825-0097',
- ContactEmailAddressC.encode(new VerifiedContactEmailAddress({ value: 'jcarberry@example.com' as EmailAddress })),
+ ContactEmailAddressC.encode(new VerifiedContactEmailAddress({ value: EmailAddress('jcarberry@example.com') })),
)
await use(contactEmailAddressStore)
@@ -2094,7 +2094,7 @@ export const invitedToBeAnAuthor: Fixtures<
'bec5727e-9992-4f3b-85be-6712df617b9d',
AuthorInviteC.encode({
status: 'open',
- emailAddress: 'jcarberry@example.com' as EmailAddress,
+ emailAddress: EmailAddress('jcarberry@example.com'),
review: 1055806,
}),
)
@@ -2102,7 +2102,7 @@ export const invitedToBeAnAuthor: Fixtures<
const email = createAuthorInviteEmail(
{
name: 'Josiah Carberry' as NonEmptyString,
- emailAddress: 'jcarberry@example.com' as EmailAddress,
+ emailAddress: EmailAddress('jcarberry@example.com'),
},
'bec5727e-9992-4f3b-85be-6712df617b9d' as Uuid,
{
diff --git a/src/club-details.ts b/src/club-details.ts
index 46f51d4a6..b98b925dc 100644
--- a/src/club-details.ts
+++ b/src/club-details.ts
@@ -7,7 +7,7 @@ import { Eq as stringEq } from 'fp-ts/lib/string.js'
import { Orcid, Eq as eqOrcid } from 'orcid-id-ts'
import { type Html, html } from './html.js'
import type { ClubId } from './types/club-id.js'
-import type { EmailAddress } from './types/email-address.js'
+import { EmailAddress } from './types/email-address.js'
export interface Club {
readonly name: string
@@ -197,7 +197,7 @@ const clubs: RR.ReadonlyRecord = {
orcid: Orcid('0000-0002-5815-8703'),
},
],
- contact: 'jenny.leopold@medizin.uni-leipzig.de' as EmailAddress,
+ contact: EmailAddress('jenny.leopold@medizin.uni-leipzig.de'),
},
bios2: {
name: 'Computational Biodiversity Science and Services',
@@ -330,7 +330,7 @@ const clubs: RR.ReadonlyRecord = {
{ name: 'Surya Nedunchezhiyan', orcid: Orcid('0009-0008-3322-2327') },
{ name: 'Tiffany I. Leung', orcid: Orcid('0000-0002-6007-4023') },
],
- contact: 'ed-support@jmir.org' as EmailAddress,
+ contact: EmailAddress('ed-support@jmir.org'),
},
'language-club': {
name: 'Language Club',
@@ -372,7 +372,7 @@ const clubs: RR.ReadonlyRecord = {
{ name: 'Luis Alberto Bezares Calderón', orcid: Orcid('0000-0001-6678-6876') },
{ name: 'Alexandra Kerbl', orcid: Orcid('0000-0002-9454-6359') },
],
- contact: 'lab239@exeter.ac.uk' as EmailAddress,
+ contact: EmailAddress('lab239@exeter.ac.uk'),
},
neuroden: {
name: 'Neuroden',
@@ -394,7 +394,7 @@ const clubs: RR.ReadonlyRecord = {
{ name: 'Abbas Saifuddin', orcid: Orcid('0009-0003-9667-6207') },
{ name: 'Hamza Mustafa', orcid: Orcid('0009-0006-0344-5365') },
],
- contact: 'hsa230003@utdallas.edu' as EmailAddress,
+ contact: EmailAddress('hsa230003@utdallas.edu'),
},
'nsa-utd': {
name: 'Neuroscience Student Association at UTD',
@@ -414,7 +414,7 @@ const clubs: RR.ReadonlyRecord = {
{ name: 'Emma Unger', orcid: Orcid('0009-0000-6854-2621') },
{ name: 'Mohammad Khan', orcid: Orcid('0009-0007-7940-1964') },
],
- contact: 'msj220001@utdallas.edu' as EmailAddress,
+ contact: EmailAddress('msj220001@utdallas.edu'),
},
'open-box-science': {
name: 'Open Box Science',
@@ -453,7 +453,7 @@ const clubs: RR.ReadonlyRecord = {
`,
leads: [{ name: 'Assist. Prof. Dr. Salwan M. Abdulateef', orcid: Orcid('0000-0002-7389-0003') }],
- contact: 'ag.salwan.mahmood@uoanbar.edu.iq' as EmailAddress,
+ contact: EmailAddress('ag.salwan.mahmood@uoanbar.edu.iq'),
},
'open-science-community-uruguay': {
name: 'Open Science Community Uruguay (OSCU)',
@@ -469,7 +469,7 @@ const clubs: RR.ReadonlyRecord = {
{ name: 'Daniel Prieto', orcid: Orcid('0000-0001-8356-1708') },
{ name: 'Mateo Vidal Panario', orcid: Orcid('0009-0009-3980-7163') },
],
- contact: 'csilvera@fcien.edu.uy' as EmailAddress,
+ contact: EmailAddress('csilvera@fcien.edu.uy'),
},
oxplants: {
name: 'OxPlants Preprint Club',
@@ -517,7 +517,7 @@ const clubs: RR.ReadonlyRecord = {
`,
leads: [{ name: 'Alain Manuel Chaple Gil', orcid: Orcid('0000-0002-8571-4429') }],
- contact: 'alain.chaple@uautonoma.cl' as EmailAddress,
+ contact: EmailAddress('alain.chaple@uautonoma.cl'),
},
'rr-id-student-reviewer-club': {
name: 'RR\\ID Student Reviewer Club',
@@ -537,7 +537,7 @@ const clubs: RR.ReadonlyRecord = {
`,
leads: [{ name: 'Hildy Fong Baker', orcid: Orcid('0000-0002-3836-1966') }],
- contact: 'rrid@berkeley.edu' as EmailAddress,
+ contact: EmailAddress('rrid@berkeley.edu'),
},
'sg-biofilms-microbiome': {
name: 'SG Biofilms and Microbiome Club',
diff --git a/src/email.ts b/src/email.ts
index f9d8e50e4..34456a760 100644
--- a/src/email.ts
+++ b/src/email.ts
@@ -17,7 +17,7 @@ import {
verifyContactEmailAddressMatch,
writeReviewVerifyEmailAddressMatch,
} from './routes.js'
-import type { EmailAddress } from './types/email-address.js'
+import { EmailAddress } from './types/email-address.js'
import type { IndeterminatePreprintId } from './types/preprint-id.js'
import type { NonEmptyString } from './types/string.js'
import type { User } from './user.js'
@@ -47,7 +47,7 @@ export const sendContactEmailAddressVerificationEmail = (
R.asks(
({ locale }: { locale: SupportedLocale }) =>
({
- from: { address: 'help@prereview.org' as EmailAddress, name: 'PREreview' },
+ from: { address: EmailAddress('help@prereview.org'), name: 'PREreview' },
to: { address: emailAddress.value, name: user.name },
subject: translate(locale, 'email', 'verifyEmailAddressTitle')(),
text: `${translate(locale, 'email', 'hiName')({ name: user.name })}\n\n${translate(locale, 'email', 'verifyEmailAddressGoingTo')({ link: verificationUrl.href })}`,
@@ -86,7 +86,7 @@ export const sendContactEmailAddressVerificationEmailForReview = (
R.asks(
({ locale }: { locale: SupportedLocale }) =>
({
- from: { address: 'help@prereview.org' as EmailAddress, name: 'PREreview' },
+ from: { address: EmailAddress('help@prereview.org'), name: 'PREreview' },
to: { address: emailAddress.value, name: user.name },
subject: translate(locale, 'email', 'verifyEmailAddressTitle')(),
text: `${translate(locale, 'email', 'hiName')({ name: user.name })}\n\n${translate(locale, 'email', 'verifyEmailAddressGoingTo')({ link: verificationUrl.href })}`,
@@ -127,7 +127,7 @@ export const createContactEmailAddressVerificationEmailForInvitedAuthor = ({
R.asks(
({ locale }: { locale: SupportedLocale }) =>
({
- from: { address: 'help@prereview.org' as EmailAddress, name: 'PREreview' },
+ from: { address: EmailAddress('help@prereview.org'), name: 'PREreview' },
to: { address: emailAddress.value, name: user.name },
subject: translate(locale, 'email', 'verifyEmailAddressTitle')(),
text: `${translate(locale, 'email', 'hiName')({ name: user.name })}\n\n${translate(locale, 'email', 'verifyEmailAddressGoingTo')({ link: verificationUrl.href })}`,
@@ -168,7 +168,7 @@ export const createContactEmailAddressVerificationEmailForComment = ({
R.map(
verificationUrl =>
({
- from: { address: 'help@prereview.org' as EmailAddress, name: 'PREreview' },
+ from: { address: EmailAddress('help@prereview.org'), name: 'PREreview' },
to: { address: emailAddress.value, name: user.name },
subject: translate(locale, 'email', 'verifyEmailAddressTitle')(),
text: `${translate(locale, 'email', 'hiName')({ name: user.name })}\n\n${translate(locale, 'email', 'verifyEmailAddressGoingTo')({ link: verificationUrl.href })}`,
@@ -204,7 +204,7 @@ export const createAuthorInviteEmail = (
R.map(
({ inviteUrl, declineUrl }) =>
({
- from: { address: 'help@prereview.org' as EmailAddress, name: 'PREreview' },
+ from: { address: EmailAddress('help@prereview.org'), name: 'PREreview' },
to: { address: person.emailAddress, name: person.name },
subject: 'Be listed as a PREreview author',
text: `
diff --git a/src/types/email-address.ts b/src/types/email-address.ts
index b9dda1681..549b08b69 100644
--- a/src/types/email-address.ts
+++ b/src/types/email-address.ts
@@ -27,3 +27,5 @@ export const EmailAddressSchema = pipe(
Schema.filter(s => isEmailValid(s), { message: () => 'not an email address' }),
Schema.brand(EmailAddressBrand),
)
+
+export const EmailAddress = (email: string) => EmailAddressSchema.make(email)
diff --git a/test/fc.ts b/test/fc.ts
index f22cf02bd..77ea57f1b 100644
--- a/test/fc.ts
+++ b/test/fc.ts
@@ -75,7 +75,7 @@ import {
isNonCacheable,
} from '../src/status-code.js'
import { type ClubId, clubIds } from '../src/types/club-id.js'
-import type { EmailAddress } from '../src/types/email-address.js'
+import { EmailAddress } from '../src/types/email-address.js'
import { type FieldId, fieldIds } from '../src/types/field.js'
import { ProfileId } from '../src/types/index.js'
import {
@@ -379,7 +379,7 @@ const asset = (): fc.Arbitrary =>
const js = (): fc.Arbitrary> =>
asset().filter((asset): asset is EndsWith => asset.endsWith('.js'))
-export const emailAddress = (): fc.Arbitrary => fc.emailAddress() as fc.Arbitrary
+export const emailAddress = (): fc.Arbitrary => fc.emailAddress().map(EmailAddress)
export const contactEmailAddress = (): fc.Arbitrary =>
fc.oneof(unverifiedContactEmailAddress(), verifiedContactEmailAddress())
diff --git a/visual-regression/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressPage.spec.ts b/visual-regression/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressPage.spec.ts
index 4fe02c10e..197ae1145 100644
--- a/visual-regression/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressPage.spec.ts
+++ b/visual-regression/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressPage.spec.ts
@@ -1,6 +1,6 @@
import { Either } from 'effect'
import { DefaultLocale } from '../../../src/locales/index.js'
-import type { EmailAddress, Uuid } from '../../../src/types/index.js'
+import { EmailAddress, type Uuid } from '../../../src/types/index.js'
import * as EnterEmailAddressForm from '../../../src/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressForm.js'
import * as _ from '../../../src/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressPage.js'
import { expect, test } from '../../base.js'
@@ -21,7 +21,7 @@ test('content looks right when there is an email address', async ({ showPage })
const response = _.EnterEmailAddressPage({
commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid,
form: new EnterEmailAddressForm.CompletedForm({
- emailAddress: 'jcarberry@example.com' as EmailAddress.EmailAddress,
+ emailAddress: EmailAddress.EmailAddress('jcarberry@example.com'),
}),
locale: DefaultLocale,
})
diff --git a/visual-regression/WriteCommentFlow/NeedToVerifyEmailAddressPage/NeedToVerifyEmailAddressPage.spec.ts b/visual-regression/WriteCommentFlow/NeedToVerifyEmailAddressPage/NeedToVerifyEmailAddressPage.spec.ts
index 4a4ef4304..dfa4f6679 100644
--- a/visual-regression/WriteCommentFlow/NeedToVerifyEmailAddressPage/NeedToVerifyEmailAddressPage.spec.ts
+++ b/visual-regression/WriteCommentFlow/NeedToVerifyEmailAddressPage/NeedToVerifyEmailAddressPage.spec.ts
@@ -1,12 +1,12 @@
import { DefaultLocale } from '../../../src/locales/index.js'
-import type { EmailAddress, Uuid } from '../../../src/types/index.js'
+import { EmailAddress, type Uuid } from '../../../src/types/index.js'
import * as _ from '../../../src/WriteCommentFlow/NeedToVerifyEmailAddressPage/NeedToVerifyEmailAddressPage.js'
import { expect, test } from '../../base.js'
test('content looks right', async ({ showPage }) => {
const response = _.NeedToVerifyEmailAddressPage({
commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid,
- emailAddress: 'jcarberry@example.com' as EmailAddress.EmailAddress,
+ emailAddress: EmailAddress.EmailAddress('jcarberry@example.com'),
locale: DefaultLocale,
})
diff --git a/visual-regression/author-invite-flow/author-invite-enter-email-address.test.ts b/visual-regression/author-invite-flow/author-invite-enter-email-address.test.ts
index e2fb79404..e2990e0dd 100644
--- a/visual-regression/author-invite-flow/author-invite-enter-email-address.test.ts
+++ b/visual-regression/author-invite-flow/author-invite-enter-email-address.test.ts
@@ -2,13 +2,13 @@ import * as E from 'fp-ts/lib/Either.js'
import type { Uuid } from 'uuid-ts'
import { enterEmailAddressForm } from '../../src/author-invite-flow/enter-email-address-page/enter-email-address-form.js'
import { invalidE, missingE } from '../../src/form.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import { expect, test } from '../base.js'
test('content looks right', async ({ showPage }) => {
const response = enterEmailAddressForm({
inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid,
- invitedEmailAddress: 'jcarberry@example.com' as EmailAddress,
+ invitedEmailAddress: EmailAddress('jcarberry@example.com'),
form: { useInvitedAddress: E.right(undefined), otherEmailAddress: E.right(undefined) },
})
@@ -21,7 +21,7 @@ test('content looks right when fields are missing', async ({ showPage }) => {
await test.step('choice field', async () => {
const response = enterEmailAddressForm({
inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid,
- invitedEmailAddress: 'jcarberry@example.com' as EmailAddress,
+ invitedEmailAddress: EmailAddress('jcarberry@example.com'),
form: { useInvitedAddress: E.left(missingE()), otherEmailAddress: E.right(undefined) },
})
@@ -33,7 +33,7 @@ test('content looks right when fields are missing', async ({ showPage }) => {
await test.step('other email address field', async () => {
const response = enterEmailAddressForm({
inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid,
- invitedEmailAddress: 'jcarberry@example.com' as EmailAddress,
+ invitedEmailAddress: EmailAddress('jcarberry@example.com'),
form: { useInvitedAddress: E.right('no'), otherEmailAddress: E.left(missingE()) },
})
@@ -46,7 +46,7 @@ test('content looks right when fields are missing', async ({ showPage }) => {
test('content looks right when fields are invalid', async ({ showPage }) => {
const response = enterEmailAddressForm({
inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid,
- invitedEmailAddress: 'jcarberry@example.com' as EmailAddress,
+ invitedEmailAddress: EmailAddress('jcarberry@example.com'),
form: { useInvitedAddress: E.right('no'), otherEmailAddress: E.left(invalidE('not an email address')) },
})
diff --git a/visual-regression/author-invite-flow/author-invite-need-to-verify-email-address.test.ts b/visual-regression/author-invite-flow/author-invite-need-to-verify-email-address.test.ts
index b5b14d176..e37e3cad6 100644
--- a/visual-regression/author-invite-flow/author-invite-need-to-verify-email-address.test.ts
+++ b/visual-regression/author-invite-flow/author-invite-need-to-verify-email-address.test.ts
@@ -1,14 +1,14 @@
import type { Uuid } from 'uuid-ts'
import { needToVerifyEmailAddressPage } from '../../src/author-invite-flow/need-to-verify-email-address-page/need-to-verify-email-address-page.js'
import { UnverifiedContactEmailAddress } from '../../src/contact-email-address.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import { expect, test } from '../base.js'
test('content looks right', async ({ showPage }) => {
const response = needToVerifyEmailAddressPage({
inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid,
contactEmailAddress: new UnverifiedContactEmailAddress({
- value: 'jcarberry@example.com' as EmailAddress,
+ value: EmailAddress('jcarberry@example.com'),
verificationToken: '2a29e36c-da26-438d-9a67-577101fa8968' as Uuid,
}),
})
diff --git a/visual-regression/author-invite-flow/author-invite-start.test.ts b/visual-regression/author-invite-flow/author-invite-start.test.ts
index d0dcdf01c..d040f7c55 100644
--- a/visual-regression/author-invite-flow/author-invite-start.test.ts
+++ b/visual-regression/author-invite-flow/author-invite-start.test.ts
@@ -3,7 +3,7 @@ import { Orcid } from 'orcid-id-ts'
import type { Uuid } from 'uuid-ts'
import { authorInviteStart } from '../../src/author-invite-flow/index.js'
import { html } from '../../src/html.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import type { Pseudonym } from '../../src/types/pseudonym.js'
import { expect, test } from '../base.js'
@@ -19,7 +19,7 @@ test('content looks right when already started', async ({ showPage }) => {
getAuthorInvite: () =>
TE.right({
status: 'assigned',
- emailAddress: 'jcarberry@example.com' as EmailAddress,
+ emailAddress: EmailAddress('jcarberry@example.com'),
orcid: Orcid('0000-0002-1825-0097'),
review: 1234,
}),
diff --git a/visual-regression/author-invite-flow/author-invite.test.ts b/visual-regression/author-invite-flow/author-invite.test.ts
index 2bd91097f..42008ca41 100644
--- a/visual-regression/author-invite-flow/author-invite.test.ts
+++ b/visual-regression/author-invite-flow/author-invite.test.ts
@@ -5,7 +5,7 @@ import { Orcid } from 'orcid-id-ts'
import type { Uuid } from 'uuid-ts'
import { authorInvite } from '../../src/author-invite-flow/index.js'
import { html } from '../../src/html.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import type { Pseudonym } from '../../src/types/pseudonym.js'
import { expect, test } from '../base.js'
@@ -14,7 +14,7 @@ import PlainDate = Temporal.PlainDate
test('content looks right', async ({ showPage }) => {
const response = await authorInvite({ id: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid })({
getAuthorInvite: () =>
- TE.right({ status: 'open', emailAddress: 'jcarberry@example.com' as EmailAddress, review: 1234 }),
+ TE.right({ status: 'open', emailAddress: EmailAddress('jcarberry@example.com'), review: 1234 }),
getPrereview: () =>
TE.right({
authors: {
@@ -73,7 +73,7 @@ test('content looks right when logged in', async ({ showPage }) => {
},
})({
getAuthorInvite: () =>
- TE.right({ status: 'open', emailAddress: 'jcarberry@example.com' as EmailAddress, review: 1234 }),
+ TE.right({ status: 'open', emailAddress: EmailAddress('jcarberry@example.com'), review: 1234 }),
getPrereview: () =>
TE.right({
authors: {
diff --git a/visual-regression/club-profile-page/club-profile-page.spec.ts b/visual-regression/club-profile-page/club-profile-page.spec.ts
index d28c81031..46bcc8959 100644
--- a/visual-regression/club-profile-page/club-profile-page.spec.ts
+++ b/visual-regression/club-profile-page/club-profile-page.spec.ts
@@ -7,7 +7,7 @@ import type { Prereviews } from '../../src/club-profile-page/prereviews.js'
import { html, rawHtml } from '../../src/html.js'
import { DefaultLocale } from '../../src/locales/index.js'
import type { ClubId } from '../../src/types/club-id.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import { expect, test } from '../base.js'
import PlainDate = Temporal.PlainDate
@@ -45,7 +45,7 @@ const club1 = {
{ name: 'Arpita Ghosh', orcid: Orcid('0009-0003-2106-3270') },
{ name: 'Garima Jain', orcid: Orcid('0000-0002-8079-9611') },
],
- contact: 'email@example.com' as EmailAddress,
+ contact: EmailAddress('email@example.com'),
joinLink: new URL(
'https://docs.google.com/forms/d/e/1FAIpQLScOR3oM_9OOhRKxjQvupN8YLtaGImOfKskkllrveTWIqrJUVg/viewform',
),
diff --git a/visual-regression/email.spec.ts b/visual-regression/email.spec.ts
index be4b765cd..8b16762da 100644
--- a/visual-regression/email.spec.ts
+++ b/visual-regression/email.spec.ts
@@ -9,7 +9,7 @@ import {
} from '../src/email.js'
import { html } from '../src/html.js'
import { DefaultLocale } from '../src/locales/index.js'
-import type { EmailAddress } from '../src/types/email-address.js'
+import { EmailAddress } from '../src/types/email-address.js'
import type { Pseudonym } from '../src/types/pseudonym.js'
import type { NonEmptyString } from '../src/types/string.js'
import { expect, test } from './base.js'
@@ -22,7 +22,7 @@ test('email-verification HTML for an invited author looks right', async ({ page
pseudonym: 'Orange Panda' as Pseudonym,
},
emailAddress: new UnverifiedContactEmailAddress({
- value: 'jcarberry@example.com' as EmailAddress,
+ value: EmailAddress('jcarberry@example.com'),
verificationToken: '2a29e36c-da26-438d-9a67-577101fa8968' as Uuid,
}),
authorInvite: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid,
@@ -41,7 +41,7 @@ test('email-verification text for an invited author looks right', async ({ page
pseudonym: 'Orange Panda' as Pseudonym,
},
emailAddress: new UnverifiedContactEmailAddress({
- value: 'jcarberry@example.com' as EmailAddress,
+ value: EmailAddress('jcarberry@example.com'),
verificationToken: '2a29e36c-da26-438d-9a67-577101fa8968' as Uuid,
}),
authorInvite: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid,
@@ -60,7 +60,7 @@ test('email-verification HTML for a comment looks right', async ({ page }) => {
pseudonym: 'Orange Panda' as Pseudonym,
},
emailAddress: new UnverifiedContactEmailAddress({
- value: 'jcarberry@example.com' as EmailAddress,
+ value: EmailAddress('jcarberry@example.com'),
verificationToken: '2a29e36c-da26-438d-9a67-577101fa8968' as Uuid,
}),
comment: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid,
@@ -80,7 +80,7 @@ test('email-verification text for a comment looks right', async ({ page }) => {
pseudonym: 'Orange Panda' as Pseudonym,
},
emailAddress: new UnverifiedContactEmailAddress({
- value: 'jcarberry@example.com' as EmailAddress,
+ value: EmailAddress('jcarberry@example.com'),
verificationToken: '2a29e36c-da26-438d-9a67-577101fa8968' as Uuid,
}),
comment: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid,
@@ -96,7 +96,7 @@ test('author-invite HTML looks right', async ({ page }) => {
const email = createAuthorInviteEmail(
{
name: 'Josiah Carberry' as NonEmptyString,
- emailAddress: 'jcarberry@example.com' as EmailAddress,
+ emailAddress: EmailAddress('jcarberry@example.com'),
},
'cda07004-01ec-4d48-8ff0-87bb32c6e81d' as Uuid,
{
@@ -121,7 +121,7 @@ test('author-invite text looks right', async ({ page }) => {
const email = createAuthorInviteEmail(
{
name: 'Josiah Carberry' as NonEmptyString,
- emailAddress: 'jcarberry@example.com' as EmailAddress,
+ emailAddress: EmailAddress('jcarberry@example.com'),
},
'cda07004-01ec-4d48-8ff0-87bb32c6e81d' as Uuid,
{
diff --git a/visual-regression/my-details/change-contact-email-address-form-page.spec.ts b/visual-regression/my-details/change-contact-email-address-form-page.spec.ts
index c73554871..48bb4d156 100644
--- a/visual-regression/my-details/change-contact-email-address-form-page.spec.ts
+++ b/visual-regression/my-details/change-contact-email-address-form-page.spec.ts
@@ -1,11 +1,11 @@
import * as E from 'fp-ts/lib/Either.js'
import { invalidE, missingE } from '../../src/form.js'
import { createFormPage } from '../../src/my-details-page/change-contact-email-address-form-page.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import { expect, test } from '../base.js'
test('content looks right', async ({ showPage }) => {
- const response = createFormPage({ emailAddress: E.right('jcarberry@example.com' as EmailAddress) })
+ const response = createFormPage({ emailAddress: E.right(EmailAddress('jcarberry@example.com')) })
const content = await showPage(response)
diff --git a/visual-regression/my-details/my-details-page.spec.ts b/visual-regression/my-details/my-details-page.spec.ts
index 1de5c0fea..f755fc5ee 100644
--- a/visual-regression/my-details/my-details-page.spec.ts
+++ b/visual-regression/my-details/my-details-page.spec.ts
@@ -3,7 +3,7 @@ import { Orcid } from 'orcid-id-ts'
import type { Uuid } from 'uuid-ts'
import { UnverifiedContactEmailAddress, VerifiedContactEmailAddress } from '../../src/contact-email-address.js'
import { createPage } from '../../src/my-details-page/my-details-page.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import type { Pseudonym } from '../../src/types/pseudonym.js'
import type { NonEmptyString } from '../../src/types/string.js'
import type { UserOnboarding } from '../../src/user-onboarding.js'
@@ -24,7 +24,7 @@ test('content looks right when publicly visible', async ({ showPage }) => {
image: new URL('https://placehold.co/48x48'),
profile: new URL('http://example.com/'),
}),
- contactEmailAddress: O.some(new VerifiedContactEmailAddress({ value: 'some-email@example.com' as EmailAddress })),
+ contactEmailAddress: O.some(new VerifiedContactEmailAddress({ value: EmailAddress('some-email@example.com') })),
openForRequests: O.some({ value: true, visibility: 'public' }),
careerStage: O.some({ value: 'mid', visibility: 'public' }),
researchInterests: O.some({
@@ -60,7 +60,7 @@ test('content looks right when restricted visible', async ({ showPage }) => {
}),
contactEmailAddress: O.some(
new UnverifiedContactEmailAddress({
- value: 'some-email@example.com' as EmailAddress,
+ value: EmailAddress('some-email@example.com'),
verificationToken: '9492b53b-ac19-4a6d-966c-5d2f27e80b83' as Uuid,
}),
),
diff --git a/visual-regression/write-review/write-review-add-authors.spec.ts b/visual-regression/write-review/write-review-add-authors.spec.ts
index 0c495e853..0b60e4cb4 100644
--- a/visual-regression/write-review/write-review-add-authors.spec.ts
+++ b/visual-regression/write-review/write-review-add-authors.spec.ts
@@ -4,7 +4,7 @@ import { missingE } from '../../src/form.js'
import { html } from '../../src/html.js'
import { DefaultLocale } from '../../src/locales/index.js'
import type { PreprintTitle } from '../../src/preprint.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import type { NonEmptyString } from '../../src/types/string.js'
import { addAuthorsForm } from '../../src/write-review/add-authors-page/add-authors-form.js'
import { expect, test } from '../base.js'
@@ -22,7 +22,7 @@ const locale = DefaultLocale
test('content looks right when there is another author', async ({ showPage }) => {
const response = addAuthorsForm({
- authors: [{ name: 'Josiah Carberry' as NonEmptyString, emailAddress: 'jcarberry@example.com' as EmailAddress }],
+ authors: [{ name: 'Josiah Carberry' as NonEmptyString, emailAddress: EmailAddress('jcarberry@example.com') }],
form: {
anotherAuthor: E.right(undefined),
},
@@ -38,10 +38,10 @@ test('content looks right when there is another author', async ({ showPage }) =>
test('content looks right when there are other authors', async ({ showPage }) => {
const response = addAuthorsForm({
authors: [
- { name: 'Josiah Carberry' as NonEmptyString, emailAddress: 'jcarberry@example.com' as EmailAddress },
- { name: 'Jean-Baptiste Botul' as NonEmptyString, emailAddress: 'jbbotul@example.com' as EmailAddress },
- { name: 'Arne Saknussemm' as NonEmptyString, emailAddress: 'asaknussemm@example.com' as EmailAddress },
- { name: 'Otto Lidenbrock' as NonEmptyString, emailAddress: 'olidenbrock@example.com' as EmailAddress },
+ { name: 'Josiah Carberry' as NonEmptyString, emailAddress: EmailAddress('jcarberry@example.com') },
+ { name: 'Jean-Baptiste Botul' as NonEmptyString, emailAddress: EmailAddress('jbbotul@example.com') },
+ { name: 'Arne Saknussemm' as NonEmptyString, emailAddress: EmailAddress('asaknussemm@example.com') },
+ { name: 'Otto Lidenbrock' as NonEmptyString, emailAddress: EmailAddress('olidenbrock@example.com') },
],
form: {
anotherAuthor: E.right(undefined),
@@ -57,7 +57,7 @@ test('content looks right when there are other authors', async ({ showPage }) =>
test('content looks right when fields are missing', async ({ showPage }) => {
const response = addAuthorsForm({
- authors: [{ name: 'Josiah Carberry' as NonEmptyString, emailAddress: 'jcarberry@example.com' as EmailAddress }],
+ authors: [{ name: 'Josiah Carberry' as NonEmptyString, emailAddress: EmailAddress('jcarberry@example.com') }],
form: {
anotherAuthor: E.left(missingE()),
},
diff --git a/visual-regression/write-review/write-review-change-author.spec.ts b/visual-regression/write-review/write-review-change-author.spec.ts
index 333c9428c..62511c577 100644
--- a/visual-regression/write-review/write-review-change-author.spec.ts
+++ b/visual-regression/write-review/write-review-change-author.spec.ts
@@ -4,7 +4,7 @@ import { invalidE, missingE } from '../../src/form.js'
import { html } from '../../src/html.js'
import { DefaultLocale } from '../../src/locales/index.js'
import type { PreprintTitle } from '../../src/preprint.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import type { NonEmptyString } from '../../src/types/string.js'
import { changeAuthorForm } from '../../src/write-review/change-author-page/change-author-form.js'
import { expect, test } from '../base.js'
@@ -25,7 +25,7 @@ test('content looks right', async ({ showPage }) => {
author: { name: 'Josiah Carberry' as NonEmptyString },
form: {
name: E.right('Josiah Carberry' as NonEmptyString),
- emailAddress: E.right('jcarberry@example.com' as EmailAddress),
+ emailAddress: E.right(EmailAddress('jcarberry@example.com')),
},
number: 1,
preprint,
diff --git a/visual-regression/write-review/write-review-publish.spec.ts b/visual-regression/write-review/write-review-publish.spec.ts
index 5dad6d293..cd34b0264 100644
--- a/visual-regression/write-review/write-review-publish.spec.ts
+++ b/visual-regression/write-review/write-review-publish.spec.ts
@@ -3,7 +3,7 @@ import { Orcid } from 'orcid-id-ts'
import { html } from '../../src/html.js'
import { DefaultLocale } from '../../src/locales/index.js'
import type { PreprintTitle } from '../../src/preprint.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import type { Pseudonym } from '../../src/types/pseudonym.js'
import type { NonEmptyString } from '../../src/types/string.js'
import type { User } from '../../src/user.js'
@@ -106,9 +106,9 @@ test('content looks right when there are other authors', async ({ showPage }) =>
persona: 'public',
moreAuthors: 'yes',
otherAuthors: [
- { name: 'Jean-Baptiste Botul' as NonEmptyString, emailAddress: 'jbbotul@example.com' as EmailAddress },
- { name: 'Arne Saknussemm' as NonEmptyString, emailAddress: 'asaknussemm@example.com' as EmailAddress },
- { name: 'Otto Lidenbrock' as NonEmptyString, emailAddress: 'olidenbrock@example.com' as EmailAddress },
+ { name: 'Jean-Baptiste Botul' as NonEmptyString, emailAddress: EmailAddress('jbbotul@example.com') },
+ { name: 'Arne Saknussemm' as NonEmptyString, emailAddress: EmailAddress('asaknussemm@example.com') },
+ { name: 'Otto Lidenbrock' as NonEmptyString, emailAddress: EmailAddress('olidenbrock@example.com') },
],
competingInterests: 'no',
conduct: 'yes',
diff --git a/visual-regression/write-review/write-review-published.spec.ts b/visual-regression/write-review/write-review-published.spec.ts
index 2896e2bb9..408cf671e 100644
--- a/visual-regression/write-review/write-review-published.spec.ts
+++ b/visual-regression/write-review/write-review-published.spec.ts
@@ -3,7 +3,7 @@ import { Orcid } from 'orcid-id-ts'
import { html } from '../../src/html.js'
import { DefaultLocale } from '../../src/locales/index.js'
import type { PreprintTitle } from '../../src/preprint.js'
-import type { EmailAddress } from '../../src/types/email-address.js'
+import { EmailAddress } from '../../src/types/email-address.js'
import type { Pseudonym } from '../../src/types/pseudonym.js'
import type { NonEmptyString } from '../../src/types/string.js'
import type { User } from '../../src/user.js'
@@ -62,9 +62,9 @@ test('content looks right when there are more authors', async ({ page, showHtml,
...form,
moreAuthors: 'yes',
otherAuthors: [
- { name: 'Jean-Baptiste Botul' as NonEmptyString, emailAddress: 'jbbotul@example.com' as EmailAddress },
- { name: 'Arne Saknussemm' as NonEmptyString, emailAddress: 'asaknussemm@example.com' as EmailAddress },
- { name: 'Otto Lidenbrock' as NonEmptyString, emailAddress: 'olidenbrock@example.com' as EmailAddress },
+ { name: 'Jean-Baptiste Botul' as NonEmptyString, emailAddress: EmailAddress('jbbotul@example.com') },
+ { name: 'Arne Saknussemm' as NonEmptyString, emailAddress: EmailAddress('asaknussemm@example.com') },
+ { name: 'Otto Lidenbrock' as NonEmptyString, emailAddress: EmailAddress('olidenbrock@example.com') },
],
},
},