コード例 #1
0
        public Tuple <bool, string> VerifyPassword(string password, PasswordValidator validator)
        {
            if (password == null)
            {
                throw new ArgumentException($"{password} is null arg");
            }

            if (password == string.Empty)
            {
                return(Tuple.Create(false, $"{password} is empty "));
            }

            if (validator == null)
            {
                return(VerifyPassword(password));
            }

            bool result = true;

            foreach (PasswordValidator rule in validator.GetInvocationList())
            {
                result &= rule(password);
            }

            if (!result)
            {
                return(Tuple.Create(false, $"{password} is not valid"));
            }

            _repository.Create(password);

            return(Tuple.Create(true, "Password is Ok. User was created"));
        }