How to use is-email - 6 common examples

To help you get started, we’ve selected a few is-email examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cusspvz / contact-email.microservice / src / routes / email.js View on Github external
const options = {
        from: from || env.EMAIL_DEFAULT_FROM,
        to: to || env.EMAIL_DEFAULT_TO,
        subject: subject || env.EMAIL_DEFAULT_SUBJECT,
        html: compiledTemplate.html(dataset),
        text: compiledTemplate.text(dataset),
      }

      if ( env.EMAIL_FROM_VALIDATE_IN ) {
        const valid_emails = env.EMAIL_FROM_VALIDATE_IN.split(',')
        if ( valid_emails.indexOf(options.from) === -1 ) {
          throw { message: 'The provided `from` email is not allowed', code: 401 }
        }
      }

      if ( ! isEmail( options.from ) ) {
        throw { message: 'The provided `from` email is not a valid email', code: 401 }
      }

      if ( env.EMAIL_TO_VALIDATE_IN ) {
        const valid_emails = env.EMAIL_TO_VALIDATE_IN.split(',')
        if ( valid_emails.indexOf(options.to) === -1 ) {
          throw { message: 'The provided `to` email is not allowed', code: 401 }
        }
      }

      if ( ! isEmail( options.to ) ) {
        throw { message: 'The provided `to` email is not a valid email', code: 401 }
      }

      // Prevent email grouping on clients
      if (+env.EMAIL_PREVENT_GROUPING) {
github cusspvz / contact-email.microservice / src / routes / email.js View on Github external
throw { message: 'The provided `from` email is not allowed', code: 401 }
        }
      }

      if ( ! isEmail( options.from ) ) {
        throw { message: 'The provided `from` email is not a valid email', code: 401 }
      }

      if ( env.EMAIL_TO_VALIDATE_IN ) {
        const valid_emails = env.EMAIL_TO_VALIDATE_IN.split(',')
        if ( valid_emails.indexOf(options.to) === -1 ) {
          throw { message: 'The provided `to` email is not allowed', code: 401 }
        }
      }

      if ( ! isEmail( options.to ) ) {
        throw { message: 'The provided `to` email is not a valid email', code: 401 }
      }

      // Prevent email grouping on clients
      if (+env.EMAIL_PREVENT_GROUPING) {
        const id = Date.now().toString(32)
        options.subject = `[${id}] ${options.subject}`
        options.text = `${options.text}\n\nID: [${id}]`
        options.html = `${options.html}\n\n`
      }

      // check email
      await transporter.sendMail(options)
    } catch (err) {
      return next(err)
    }
github ianstormtaylor / superstruct / test / fixtures / scalar-custom / invalid-failure-object.ts View on Github external
email: (value: any): boolean | Partial => {
      if (isEmail(value)) {
        return true
      } else {
        return { reason: `not_email` }
      }
    },
  },
github shoutem / extensions / shoutem.auth / app / components / RegisterForm.js View on Github external
validateInput() {
    const { email, username, password } = this.state;

    if (_.isEmpty(email) || _.isEmpty(username) || _.isEmpty(password)) {
      Alert.alert(I18n.t('shoutem.application.errorTitle'), errorMessages.EMPTY_FIELDS);
      return false;
    }

    if (!isEmail(email)) {
      Alert.alert(I18n.t('shoutem.application.errorTitle'), errorMessages.SIGNUP_EMAIL_INVALID);
      return false;
    }

    if (!password || password.length < 6) {
      Alert.alert(I18n.t('shoutem.application.errorTitle'), errorMessages.SIGNUP_PASSWORD_INVALID);
      return false;
    }

    const usernameRegexMatch = username.match(this.usernameRegex);
    if (!username || !usernameRegexMatch) {
      Alert.alert(I18n.t('shoutem.application.errorTitle'), errorMessages.SIGNUP_USERNAME_INVALID);
      return false;
    }

    return true;
github ianstormtaylor / superstruct / examples / custom-types.js View on Github external
email: v => {
      if (!isEmail(v)) return `not_email`
      if (v.length >= 256) return 'too_long'
      return true
    },
    url: v => isUrl(v) && v.length < 2048,

is-email

Loosely validate an email address.

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular is-email functions