abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.92k stars 3.44k forks source link

[Angular UI] User form is not mapping backend validation errors #10926

Open begandroide opened 2 years ago

begandroide commented 2 years ago

Hi! im adding validation errors to my app and i has an issue with validation in user module with creation of user with username: admin (or one existing). The problem is that validation error is showed in dialog (fine) but not is mapped to form field (username in this case). I'm missing something in api configuration? (I attached a gif to see the behaviour).

Steps to reproduce the problem

  1. Clone a clean project of abp using Angular UI
  2. Login in angular and go in user module
  3. Add a new user with username admin
  4. Validation error is showed in dialog but not mapped to form field ngx-validate

Second question

Exists a more automatic way to map backend errors to form field? I'm mapping errors like that:

request.subscribe(response => {
      this.getList.emit(true);
      this.close();
    }, (httpError: HttpErrorResponse) => {
      console.log(httpError);
      const { error } = httpError.error;
      const { validationErrors } = error;

      validationErrors.forEach(({ message, members }) => {
        members.forEach(member => {
          this.form.get(member).setErrors({ 'uniqueTopic': message });
        });
      });
});

Is like pretty much restrictive like im mapping well known validation error. In addition of before code, I need to add blueprint in themesharedmodule. But im searching for something more faster to map.

mehmet-erim commented 2 years ago

Hi @begandroide

It is so hard to implement it in entire forms. You should keep doing this manually. However, it is a good idea. I'm marking this one as a feature request.

Thanks!