Exemplo n.º 1
0
        public bool Register(User user)
        {
            try
            {
                var handler = new UserValidationHandler(
                    new AgeValidationHandler(),
                    new NameValidationHandler(),
                    new CitizenshipRegionValidationHandler());

                //handler.SetNext(new CitizenshipRegionValidationHandler());

                handler.Handle(user);
            }
            catch (UserValidationException ex)
            {
                return(false);
            }

            return(true);
        }
 public CreateUserRequestValidator(UserValidationHandler handler)
 {
     _handler = handler;
     RuleFor(x => x.Login).Must(x => !_handler.LoginExists(x)).WithMessage("Login juz istnieje w bazie");
     RuleFor(x => x.Email).Must(x => !_handler.EmailExists(x)).WithMessage("Email juz istnieje w bazie");
 }
Exemplo n.º 3
0
        public AuthUserRequestValidator(UserValidationHandler handler)
        {
            _handler = handler;

            RuleFor(x => x).Must(x => _handler.ValidateAuth(x.Login, x.Password)).WithMessage("Dane nieprawidlowe");
        }