示例#1
0
        public void Validate(RegisterViewModel model, ValidatorAction action = ValidatorAction.Register)
        {
            if (model == null)
            {
                AddError("You provided no data");
                return;
            }

            if (entityService.IsNameTaken(model.Name))
            {
                AddError("Name is taken", () => model.Name);
            }

            if (entityService.IsSpecialName(model.Name))
            {
                AddError("This is special name. You cannot use it", () => model.Name);
            }

            if (citizenRepository.IsEmailAddressAllowed(model.Email) == false)
            {
                AddError("Email address not registered for beta!");
            }
            else if (citizenRepository.IsEmailAddressUsed(model.Email))
            {
                AddError("Email address is already used!");
            }
        }