public async Task <ValidationQueryResult> ExecuteAsync(ValidateUsernameQuery query, IExecutionContext executionContext)
        {
            var userArea         = _userAreaDefinitionRepository.GetRequiredByCode(query.UserAreaCode);
            var formattingResult = _userDataFormatter.FormatUsername(userArea, query.Username);

            var context = new UsernameValidationContext()
            {
                Username         = formattingResult,
                ExecutionContext = executionContext,
                PropertyName     = nameof(query.Username),
                UserAreaCode     = userArea.UserAreaCode,
                UserId           = query.UserId
            };

            var errors = await _usernameValidator.GetErrorsAsync(context);

            var result = new ValidationQueryResult(errors.FirstOrDefault());

            return(result);
        }
        private async Task ValidateNewUsernameAsync(
            IUserAreaDefinition userArea,
            UsernameFormattingResult username,
            User user,
            IExecutionContext executionContext
            )
        {
            var context = new UsernameValidationContext()
            {
                Username         = username,
                ExecutionContext = executionContext,
                PropertyName     = userArea.UseEmailAsUsername ? EMAIL_PROPERTY : USERNAME_PROPERTY,
                UserAreaCode     = userArea.UserAreaCode
            };

            if (user.UserId > 0)
            {
                context.UserId = user.UserId;
            }

            await _usernameValidator.ValidateAsync(context);
        }