/// <summary> /// 正常登录时,验证实体参数 /// </summary> /// <param name="req"></param> /// <param name="isReg">是否是注册</param> /// <returns></returns> private ResultMo CheckLoginModelState(UserRegLoginReq req, bool isReg) { if (!ModelState.IsValid) { return(new ResultMo(ResultTypes.ParaError, GetVolidMessage())); } if (!Enum.IsDefined(typeof(RegLoginType), req.type)) { return(new ResultMo(ResultTypes.ParaError, "未知的账号类型!")); } if (req.type == RegLoginType.MobileCode || (req.type == RegLoginType.Mobile && isReg)) { if (string.IsNullOrEmpty(req.pass_code)) { return(new ResultMo(ResultTypes.ParaError, "验证码不能为空!")); } } var validator = new DataTypeAttribute( req.type == RegLoginType.Mobile ? DataType.PhoneNumber : DataType.EmailAddress); return(!validator.IsValid(req.name) ? new ResultMo(ResultTypes.ParaError, "请输入正确的手机或邮箱!") : new ResultMo()); }
public void Constructor_Invalid() { var attr = new DataTypeAttribute(null); ExceptionHelper.ExpectException<InvalidOperationException>(delegate() { attr.IsValid(null); }, Resources.DataAnnotationsResources.DataTypeAttribute_EmptyDataTypeString); attr = new DataTypeAttribute(String.Empty); ExceptionHelper.ExpectException<InvalidOperationException>(delegate() { attr.IsValid(null); }, Resources.DataAnnotationsResources.DataTypeAttribute_EmptyDataTypeString); }
public void Constructor_Invalid() { var attr = new DataTypeAttribute(null); ExceptionHelper.ExpectException <InvalidOperationException>(delegate() { attr.IsValid(null); }, Resources.DataAnnotationsResources.DataTypeAttribute_EmptyDataTypeString); attr = new DataTypeAttribute(String.Empty); ExceptionHelper.ExpectException <InvalidOperationException>(delegate() { attr.IsValid(null); }, Resources.DataAnnotationsResources.DataTypeAttribute_EmptyDataTypeString); }
/// <summary> /// 正常登录时,验证实体参数 /// </summary> /// <param name="req"></param> /// <returns></returns> private ResultMo CheckLoginModelState(UserRegLoginReq req) { if (!ModelState.IsValid) return new ResultMo(ResultTypes.ParaError, GetVolidMessage()); if (!Enum.IsDefined(typeof(RegLoginType), req.type)) return new ResultMo(ResultTypes.ParaError, "未知的账号类型!"); var validator = new DataTypeAttribute( req.type == RegLoginType.Mobile ? DataType.PhoneNumber : DataType.EmailAddress); return !validator.IsValid(req.name) ? new ResultMo(ResultTypes.ParaError, "请输入正确的手机或邮箱!") : new ResultMo(); }
/// <summary> /// 正常登录时,验证实体参数 /// </summary> /// <param name="req"></param> /// <returns></returns> private Resp CheckLoginModelState(LoginNameReq req) { if (!ModelState.IsValid) { return(new Resp(RespTypes.ParaError, ModelState.GetValidHtmlMsg())); } if (!Enum.IsDefined(typeof(RegLoginType), req.type)) { return(new Resp(RespTypes.ParaError, "未知的账号类型!")); } var validator = new DataTypeAttribute(req.type == RegLoginType.Mobile ? DataType.PhoneNumber : DataType.EmailAddress); return(!validator.IsValid(req.name) ? new Resp(RespTypes.ParaError, "请输入正确的手机或邮箱!") : new Resp()); }
/// <summary> /// 检查验证登录类型 /// </summary> /// <param name="name"></param> /// <param name="type"></param> /// <returns></returns> private static Resp CheckNameType(string name, RegLoginType type) { if (string.IsNullOrEmpty(name)) { return(new Resp(RespTypes.ParaError, "name 不能为空!")); } if (!Enum.IsDefined(typeof(RegLoginType), type)) { return(new Resp(RespTypes.ParaError, "未知的账号类型!")); } var validator = new DataTypeAttribute( type == RegLoginType.Mobile ? DataType.PhoneNumber : DataType.EmailAddress); return(!validator.IsValid(name) ? new Resp(RespTypes.ParaError, "请输入正确的手机或邮箱!") : new Resp()); }
/// <inheritdoc /> public override bool IsValid(object value) { return(_dataTypeAttribute.IsValid(value)); }