Skip to content

Mask validation fails for single "0" input (regression from v15) #1583

@MatthiasDeBuXerius

Description

@MatthiasDeBuXerius

🐞 bug report

Is this a regression?

Yes, it worked in 15.2.3, after upgrading to 20.0.3 it no longer works

Before (Angular v15)
Using mask="1||0,N" (with N being 1-9) allowed typing:

0
0, followed by a digit
1

After upgrade to Angular v20
Typing only 0 fails validation. The mask now requires either:

0, followed by a digit
or 1

Simple 0 is considered invalid.

🔬 Minimal Reproduction

use mask "1||0,N":
<input
      type="text"
      mask="1||0,N"
      [patterns]="customMaskPatterns"
      [dropSpecialCharacters]="false"
      [decimalMarker]="','"
      inputmode="numeric"
    />

with patterns:

public customMaskPatterns = {
    N: { pattern: new RegExp('[0-9]') },
    0: { pattern: new RegExp('0') },
    1: { pattern: new RegExp('1') },
  };

🔥 Exception or Error


none

🌍 Your Environment

Angular Version:



@angular-devkit/schematics      20.3.8
@angular/build                  20.3.8
@angular/cdk                    20.2.11
@angular/cli                    20.3.8
@schematics/angular             20.3.8
rxjs                            7.8.2
typescript                      5.9.3
zone.js                         0.15.1

Anything else relevant?
n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions