DEV Community

Pawan
Pawan

Posted on

Pattern(/^[^+%{}~?^:#!|=*;,\[\]<>"'`\¿\-]*$/) not accepting chars x,f,b on prod build while working on dev build for Validators

I have Angular project with the following pattern with a file app.component.ts which is like as follows and I'm using angular validator version "@angular/forms": "^14.2.0" :

import { FormBuilder, FormGroup, Validators } from '@angular/forms';

 [
          Validators.required,
          Validators.pattern(/^[^+%{}~?^:#!|=*;,\[\]<>"'`\¿\-]*$/),
          Validators.maxLength(64)
        ]
Enter fullscreen mode Exit fullscreen mode

And my html file as app.component.html :

<form [formGroup]="myForm">
  <label for="name">Name:</label>
  <input type="text" id="name" formControlName="name" />

  <div *ngIf="myForm.get('name')?.hasError('required')">
    Name is required.
  </div>

  <div *ngIf="myForm.get('name')?.hasError('pattern')">
    Invalid characters in the name.
  </div>

  <div *ngIf="myForm.get('name')?.hasError('maxlength')">
    Name should not exceed 64 characters.
  </div>
</form>
Enter fullscreen mode Exit fullscreen mode

Kindly let me know why this pattern is not accepting x,f,b on production build while same is working on dev build for validator framework

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay