当前位置: 首页>>代码示例>>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;未经允许,请勿转载。