Home > database >  Why my validator of maxlenght is state reversed?
Why my validator of maxlenght is state reversed?

Time:07-07

I m facing A mallessious issue with a simple form on my angular application.

I have the following

<mat-error *ngIf="errorControlsName.hasError('minLength') || !errorControlsName.hasError('maxLength')

                || errorControlsName.hasError('pattern')">{{ 'wsForm.errors.invalidFormat' | translate }}

            </mat-error> 

My form controll

the test result

What Is blowing my ming why the error is triggered using the negation !errorControlsName.hasError('maxLength') For me it should be errorControlsName.hasError('maxLength')

m I miss understanding something ???

CodePudding user response:

Try using lowercase

.hasError('maxlength')

'minLength' probably only seems to work because your regex in 'pattern' already disallows it.

  • Related