| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Text.RegularExpressions;
- using Abp.Extensions;
- using IwbZero.Authorization.Base.Users;
- namespace WePlatform.Models.Account
- {
- public class RegisterViewModel : IValidatableObject
- {
- [Required]
- [StringLength(UserBase.MaxNameLength)]
- public string Name { get; set; }
- [Required]
- [StringLength(UserBase.MaxSurnameLength)]
- public string Surname { get; set; }
- [StringLength(UserBase.MaxUserNameLength)]
- public string UserName { get; set; }
- [Required]
- [EmailAddress]
- [StringLength(UserBase.MaxEmailAddressLength)]
- public string EmailAddress { get; set; }
- [StringLength(UserBase.MaxPlainPasswordLength)]
- public string Password { get; set; }
- public bool IsExternalLogin { get; set; }
- public string ExternalLoginAuthSchema { get; set; }
- public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
- {
- if (!UserName.IsNullOrEmpty())
- {
- var emailRegex = new Regex(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
- if (!UserName.Equals(EmailAddress) && emailRegex.IsMatch(UserName))
- {
- yield return new ValidationResult("Username cannot be an email address unless it's same with your email address !");
- }
- }
- }
- }
- }
|