當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript validator.isEmail函數代碼示例

本文整理匯總了TypeScript中validator.isEmail函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isEmail函數的具體用法?TypeScript isEmail怎麽用?TypeScript isEmail使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isEmail函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: validateEmail

function validateEmail(emailControl) {
  if (!emailControl.value || isEmail(emailControl.value)){
    return null;
  } else {
    return { 'invalidEmail': true };
  }
}
開發者ID:SayreBlades,項目名稱:testionic,代碼行數:7,代碼來源:email-validator.ts

示例2: isString

userSchema.path('email').validate(function(email: string) {
	// if you are authenticating by any of the oauth strategies, don't validate
	if (this.isNew && !this.is_local) {
		return true;
	}
	return isString(email) && isEmail(email);
}, 'Email must be in the correct format.');
開發者ID:freezy,項目名稱:node-vpdb,代碼行數:7,代碼來源:user.schema.ts

示例3: callback

    let validate = (item,callback,path) => {


        if(!_.isString(item)){
            return callback({
                errorCode: "notString",
                description: `Variable is not a string!`,
                path: path
            });
        }

        if(validator.isEmail(item)){

            callback(null,item)

        }else{

            callback({
                errorCode: "notEmail",
                description: "The value provided is not a valid email address",
                path: path
            })

        }

    };
開發者ID:Floodway,項目名稱:floodgate,代碼行數:26,代碼來源:Email.ts

示例4:

        tv4.addFormat("email", (data, schema): any => {
            if (validator.isEmail(data)) {
                return true;
            }

            return 10000;
        });
開發者ID:nick121212,項目名稱:blessing,代碼行數:7,代碼來源:validator.custom.value.ts

示例5: constructor

  constructor(name: string,
              altNames: Array<string |
                        {value: string, type: "URI" | "IP" | "DNS" | "EMAIL" | "OTHER"}>){
    super(name);

    if (!Array.isArray(altNames)) {
      throw new Error(`The altNames parameter must be a string array for the ${""
      }AltNameStore constructor, given:\n${altNames}`);
    }

    this._altNames = [];
    this._length = 0;

    for (let name of altNames) {
      if (typeof name !== "string"
          && (typeof name.value !== "string" ||
              name.type !== "URI" ||
              name.type !== "IP" ||
              name.type !== "DNS" ||
              name.type !== "EMAIL" ||
              name.type !== "OTHER")){
        throw new Error(`The altNames parameter must be an array containing strings or${""
        } objects with a valid value and type property for the${""
        } AltNameStore constructor, given:\n${altNames}`);
      }

      if (typeof name.value === "string"){
        this._altNames.push(new AlternativeName(name.type, name.value));
      } else {
        let type: "URI" | "IP" | "DNS" | "EMAIL" | "OTHER";

        const dnOpt = {
          require_tld: false,
          allow_underscores: false,
          allow_trailing_dot: true
        };

        if (validator.isIP(name)) {
          type = "IP";
        } else if (validator.isFQDN(name, dnOpt)) {
          type = "DNS";
        } else if (name.charAt(0) === "*" &&                      // wildcard case
          validator.isFQDN(name.substring(2), dnOpt)){
          type = "DNS";
        } else if (validator.isEmail(name)) {
          type = "EMAIL";
        } else if (validator.isURL(name)) {
          type = "URI";
        } else {
          type = "OTHER";
        }

        this._altNames.push(new AlternativeName(type, name));
      }

      this._length++;
    }
  }
開發者ID:zachmart,項目名稱:closedssl,代碼行數:58,代碼來源:AltNameStore.ts

示例6: validateQuery

export function validateQuery(body: any): [boolean, any] {
  let result = false,
    query = null,
    tuple: any = UTIL.kvp2tuple(body),
    key: string = tuple[0],
    value: string = tuple[1].toString().trim()

  if (['username', 'handle', 'email', 'mobile'].indexOf(key) < 0) {
    return [result, { code: ERRORS.LOGIN.UNKNOWN_QUERY }]
  } else {
    switch (key) {
      // validate user username
      case 'username':
        if (UTIL.validateUsername(value)) {
          result = true
          query = {username: value}
        } else {
          query = { code: ERRORS.LOGIN.VALID_USER_NAME_REQUIRED }
        }
      break

      // validate user handle
      case 'handle':
        if (UTIL.validateHandle(value)) {
          result = true
          query = {handle: value}
        } else {
          query = { code: ERRORS.LOGIN.VALID_USER_HANDLE_REQUIRED }
        }
      break

      // validate email address
      case 'email':
        if (validator.isEmail(value)) {
          result = true
          query = {email: value}
        } else {
          query = { code: ERRORS.LOGIN.VALID_EMAIL_ADDRESS_REQUIRED }
        }
      break

      // validate mobile phone number
      case 'mobile':
        value = UTIL.normalizeMobile(value)

        if (validator.isMobilePhone(value, CONFIG.DEFAULT_LOCALE)) {
          result = true
          query = {mobile: value}
        } else {
          query = { code: ERRORS.LOGIN.VALID_MOBILE_PHONE_NUMBER_REQUIRED }
        }
      break
    }

    return [result, query]
  }
}
開發者ID:yeegr,項目名稱:SingularJS,代碼行數:57,代碼來源:UserController.ts

示例7: function

  app.post('/register', function(req, res, next) {
    console.dir(req.body);
    var email = req.body.email;
    var fullName = req.body.fullName;
    var password = req.body.password;
    if (fullName.length<5 ||
        fullName.length>40 ||
        password.length<5 ||
        password.length>40 ||
        !validator.isEmail(email)) {
      res.status(400).end();
      return;
    }
    log.debug(req.body);
    var user = new User({username:email,email:email,fullName:fullName,fromLdap:false});
    user.save(function(err, innerUser) {
      if (err) {
        console.log(err);
        res.status(500).end();
        return;
      }
      var userPassword = new UserPassword({userId:innerUser._id,password:password});
      userPassword.save(function(err, innerUP) {
        if (err) {
          console.log(err);
          res.status(500).end();
          return;
        }

        req.body.username = req.body.email;

        passport.authenticate('local', function(err, user, info) {
          if (err) {
            log.error({message:"DB error"});
            res.status(500).end();
            return;
          }
          if (!user) {
            log.error({message:"invalid user"});
            req.session.messages = [info.message];
            res.status(500).end();
            return;
          }
          req.logIn(user, function(err) {
            if (err) {
              res.status(500).end();
              return;
            }
            res.status(200).end();
            return;
          });
        })(req, res, next);
      });
    });
  });
開發者ID:MisterTea,項目名稱:TidalWave,代碼行數:55,代碼來源:passport-handler.ts

示例8: validateEmail

export function validateEmail(control: Control) {
    if (isPresent(Validators.required(control))) {
        return null
    }

    return isEmail(control.value) ? null : {
        ctEmail: {
            valid: false,
        },
    }
}
開發者ID:matheusmariano,項目名稱:colonthree-webapp,代碼行數:11,代碼來源:email.validator.ts

示例9: processRow

    processRow(row) {
        let card = this.getCard(row.First,row.Last,row.Middle);

        card.set("n",
            (
                (row.Last || "") + ";" + 
                (row.First || "") + ";" + 
                (row.Middle || "") + ";" + 
                (row.Prefix || "") + ";"
            ).replace(/[\r\n]/g,"")
        )

        card.set("fn",
            this.formatName(row)
        )

        if(row.Organization) {
            card.set("org",row.Organization.replace(/[\r\n]/g,""));
        }
        if(row.JobTitle) {
            card.set("title",row.JobTitle.replace(/[\r\n]/g,""));
        }

        if(row.Note) {
            card.set("note",row.Note.replace(/[\r\n]/g,""));
        }

        if(row.Nickname) {
            card.set("nickname",row.Nickname.replace(/[\r\n]/g,""));
        }

        if(row.value) {
            if(validator.isEmail(row.value)) {
                card.add("email","PREF:" + row.value.replace(/[\r\n]/g,""))
            }
            else if(row.value.match(/^[\+\d\- \(\)]+$/)) {
                card.add("tel","CELL:" + row.value.replace(/[\r\n]/g,""))
            }
            else {
            }
        }
    }
開發者ID:SwadicalRag,項目名稱:address-book-converter,代碼行數:42,代碼來源:index.ts

示例10: done

}, (username: string, password: string, done: Function) => {
    let params

    if (validator.isEmail(username)) {
      params = {
        email: username
      }
    } else if (validator.isMobilePhone(username, CONFIG.DEFAULT_LOCALE)) {
      params = {
        mobile: username
      }
    } else {
      params = {
        username
      }
    }

    Object.assign(params, {
      status: CONST.STATUSES.PLATFORM.ACTIVE
    })

    Platform
    .findOne({
      username,
      status: CONST.STATUSES.PLATFORM.ACTIVE
    })
    .then((user: IPlatform) => {
      if (user) {
        user.comparePassword(password, (err: Error, isMatch: boolean) => {
          if (err) { return done(err) }
          if (!isMatch) { return done(null, false, {code: ERRORS.LOGIN.PASSWORD_INCORRECT })}
          return done(null, user, 'local')
        })
      } else {
        return done(null, false, { code: ERRORS.LOGIN.USER_NOT_FOUND })
      }
    })
    .catch((err: Error) => {
      return done(err, false)
    })
  })
開發者ID:yeegr,項目名稱:SingularJS,代碼行數:41,代碼來源:platform.ts


注:本文中的validator.isEmail函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。