MCPcopy Create free account
hub / github.com/codecombat/codecombat / validateEmails

Method validateEmails

app/views/account/SubscriptionView.js:158–173  ·  view source on GitHub ↗
(emails, render)

Source from the content-addressed store, hash-verified

156
157class EmailValidator {
158 validateEmails (emails, render) {
159 this.lastEmails = emails.join('\n')
160 // taken from http://www.regular-expressions.info/email.html
161 const emailRegex = /[A-z0-9._%+-]+@[A-z0-9.-]+\.[A-z]{2,63}/
162 this.validEmails = ((() => {
163 const result = []
164 for (const email of Array.from(emails)) {
165 if (emailRegex.test(email.trim().toLowerCase())) {
166 result.push(email)
167 }
168 }
169 return result
170 })())
171 if (this.validEmails.length < emails.length) { return this.emailsInvalid(render) }
172 return this.emailsValid(render)
173 }
174
175 emailString () {
176 if (!this.validEmails) { return }

Callers 1

Calls 2

emailsInvalidMethod · 0.95
emailsValidMethod · 0.95

Tested by

no test coverage detected