Firebase Authentication: Password must contain capital letter

后端 未结 2 721
旧时难觅i
旧时难觅i 2020-12-11 11:30

My application is linked with firebase database and authentication.

When a user creates an account, the only requirements for the password are for it to be 6 charact

2条回答
  •  庸人自扰
    2020-12-11 12:33

    Use this function. It includes range 6-15 i.e. minimum 6 and maximum 15 characters.One Capital letter , One number respectively.

    func isValidPasswordString(pwdStr:String) -> Bool {
    
        let pwdRegEx = "(?:(?:(?=.*?[0-9])(?=.*?[-!@#$%&*ˆ+=_])|(?:(?=.*?[0-9])|(?=.*?[A-Z])|(?=.*?[-!@#$%&*ˆ+=_])))|(?=.*?[a-z])(?=.*?[0-9])(?=.*?[-!@#$%&*ˆ+=_]))[A-Za-z0-9-!@#$%&*ˆ+=_]{6,15}"
    
        let pwdTest = NSPredicate(format:"SELF MATCHES %@", pwdRegEx)
        return pwdTest.evaluate(with: pwdStr)
    }
    

    This func will return true for valid password string

提交回复
热议问题