什么是密码模式检查的自定义验证器,至少有一个大写字母、小写字母和数字

What will be the Custom Validator for password pattern checking having at least one uppercase,lowercase and number

import { Directive, forwardRef, Attribute } from '@angular/core';
import { NG_VALIDATORS,Validator,Validators,AbstractControl,ValidatorFn } from '@angular/forms';

@Directive({
    selector: '[checkPattern][formControlName],[checkPattern][formControl],[checkPattern][ngModel]',
    providers: [
        { provide: NG_VALIDATORS, useExisting: forwardRef(() => PatternValidator), multi: true }
    ]
})
export class PatternValidator implements Validator {
    constructor() {}

    validate(c:AbstractControl): { [key: string]: any } {
        // self val
        let obj:any ={};
        let number:RegExp=new RegExp("/[0-9]/g")
        let capital:RegExp=new RegExp("/[A-Z]/g")
        let letter:RegExp=new RegExp("/[a-z]/g")
if(!number.test(c.value))
            {
                obj.patternNumber=true;
            }
            else
            if(obj.patternNumber)
            delete obj.patternNumber

            if(!capital.test(c.value))
            {
                obj.patternCapital=true;
            }
            else
            if(obj.patternCapital)
            delete obj.patternCapital

            if(!letter.test(c.value))
            {
                obj.patternLetter=true;
            }
            else
            if(obj.patternLetter)
            delete obj.patternLetter

            return obj;

密码可以be:1wWrt 密码不能是:1wwwrt,11111,wwww,WWWWW {password 应该至少有一个大写字母,一个小写字母,一个数字和至少 8 个字符。 只允许大写、小写和数字

此正则表达式强制要求至少包含 8 个字符,其中包含 1 个大写字母、1 个小写字母和 1 个数字。

^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$

我将它与其他字符而不是数字一起使用

<mat-form-field class="input-row">
  <input matInput formControlName="password" type="password" placeholder="{{ 'Password' | translate }}" required pattern="^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$%^&*-]).{8,}$">
  <mat-error>{{'Doesn't match password criteria' | translate}}</mat-error>
</mat-form-field>