xtreamsrl / ngx-validation-errors

Angular library to easily show input validation errors
MIT License
39 stars 11 forks source link

Custom design validation #3

Closed thelastkiller99 closed 4 years ago

thelastkiller99 commented 5 years ago

Hello, I am trying to implement a custom validation design but when I want to get the JSON text it finds it but does not return it translated in {{messages}}. I tried to use {{messages [0]}} and I could get the message but when I use variables for MINLENGTH for example it doesn't recognize them.

rams23 commented 5 years ago

I @thelastkiller99, could you please provide a reproducible example? (I suggest for example to fork this https://stackblitz.com/github/xtreamsrl/ngx-validation-errors on stackblitz)

thelastkiller99 commented 5 years ago

That same example that you propose is the one that has the error since it does not show the content of the JSON (for example NEW_HERO.NAME.ERRORS.MINLENGTH) image

rams23 commented 5 years ago

Can you show me the translation file? according to the key it should be like:

{
  "NEW_HERO": {
     "NAME" : {
        "ERRORS": {
           "MIN_LENGTH": "error message" 
         }
     }
  }
}

Moreover be aware that the custom error component do not use the translation pipe (just for showing errors keys purpose)

<div *ngIf="messages && messages.length>0">
  Custom component {{messages}}
</div>

while the standard input does

      <span class="help-block" *ngFor="let message of messages;">{{ message | translate:params }}</span>